我有一个名为friend的NSObject和另一个名为currentUser的NSObject。 朋友类型(friendToSendMimo)的currentUser中有一个属性。但每当我尝试设置另一个朋友对象...应用程序崩溃的错误:'NSInvalidArgumentException',原因:' - [currentUser setFriendToSendMimo:]:无法识别的选择发送到实例0x15d29810'在另一个NSObject中设置NSObject时,应用程序崩溃
我的问题是:我怎么能有一个来自NSObject的属性?
继承人的currentUser头:
#import "friend.h"
@interface currentUser : NSObject<NSCoding>
@property (nonatomic,strong)NSString *token;
@property (nonatomic,strong)NSString *email;
@property (nonatomic,strong)NSString *name;
@property (nonatomic,strong)UIImage *userImg;
@property (nonatomic,strong)NSString *username;
@property (nonatomic,strong)friend *friendToSendMimo; //is there another way of setting this NSObject?
和代码崩溃喜欢这里:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
//thisUser was set as currentUser
thisUser.friendToSendMimo = [thisUser.friendsList objectAtIndex:indexPath.row];
}
不是你的直接问题,但是对于其他人阅读你的代码,你应该用UpperCase字母开始你的类名。 – 2014-10-02 19:58:00
根据你使用的Xcode版本的不同,你可能需要在''implementation''中为'currentUser'提供'@synthesize friendToSendMimo;'。 – 2014-10-02 20:00:19