2013-01-11 1 views
0

J'écris une classe avec is sous-classe de PFObject (Parse.com).Custom init parse.com

Exemple: 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; 
} 

Mais quand je lance, il sont une erreur:

[PFObject setProp1:]: unrecognized selector sent to instance 0xa2707d0 
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PFObject setProp1:]: unrecognized selector sent to instance 0xa2707d0' 

Pouvez-vous me aider à résoudre cela? Merci beaucoup!!!

Problèmes résolus !!!

-(id)initWithId:(NSString*)uid { 
self = [super initWithClassName:@"Photo"]; 
[self setObjectId:targetID]; 

[self fetch]; 

self.prop1 = [self objectForKey:@"propertiseone"]; 
// other 
} 
+0

Salut les gars, j'ai résolu mon problème !!! –

+0

comment vous le résoudre .. donnez votre solution comme réponse et acceptez cette réponse –

+0

voici, merci !!! - (id) initWithId: (NSString *) uid { self = [super initWithClassName: @ "Photo"]; [self setObjectId: targetID]; [recherche automatique]; self.prop1 = [self objectForKey: @ "propertiseone"]; // autre } –

Répondre

0

Problèmes à résoudre par moi haha ​​

-(id)initWithId:(NSString*)uid { 
self = [super initWithClassName:@"Photo"]; 
[self setObjectId:targetID]; 

[self fetch]; 

self.prop1 = [self objectForKey:@"propertiseone"]; 
// other 
} 
-1

utilisation @property (readwrite, retain)