0
我正在写一些类是PFObject(Parse.com)的子类。自定义init parse.com
例子: LBSomeClass.h
@interface LBSomeClass : PFObject
@propertise (strong,nonatomic) NSString* prop1;
@propertise (strong,nonatomic) NSString* prop2;
-(id)init;
-(id)initWithId:(NSString*)uid;
@end
LBSomeClass.m
@implementation LBPhoto
@synthesize prop1;
@synthesize prop2;
-(id)init {
self = [super init];
return self;
}
-(id)initWithId:(NSString*)uid {
self = [super init];
PFQuery* query = [PFQuery queryWithClassName:@"someclass"];
self = (LBSomeClass*)[query getObjectWithId:uid];
self.prop1 = [self objectForKey:@"propertiseone"]; //error here
self.prop2 = [self objectForKey:@"propertisetwo"]; //error here
return self;
}
但是当我运行,里有一些错误:
[PFObject setProp1:]: unrecognized selector sent to instance 0xa2707d0
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PFObject setProp1:]: unrecognized selector sent to instance 0xa2707d0'
你能不能帮我解决?非常感谢!!!
问题解决了!由我
-(id)initWithId:(NSString*)uid {
self = [super initWithClassName:@"Photo"];
[self setObjectId:targetID];
[self fetch];
self.prop1 = [self objectForKey:@"propertiseone"];
// other
}
嗨,大家好,我已经解决了我的问题! –
你如何解决它..给你的解答作为答案,并接受回答 –
这里是,谢谢! - (id)initWithId:(NSString *)uid {self = [super initWithClassName:@“Photo”]; [self setObjectId:targetID]; [self fetch]; self.prop1 = [self objectForKey:@“propertiseone”]; //其他 } –