L'attribution NSInteger de propriété en Application iPhone
J'ai une table dans SQLite, je veux insérer des données dans cette table. La table a responses_id, participant_id, answer_text, answer_option_update_date_time. responses_id et participant_id sont des nombres entiers. Quand je suis en attribuant une chose à participant_id il donne une erreur, l'objet ne peut pas définir à la propriété.
@interface Coffee : NSObject {
NSInteger coffeeID;
NSInteger participant_Id;
NSString*question_Id;
NSString*answer_option;
NSString*answer_text;
NSString*update_date_time;
//Intrnal variables to keep track of the state of the object.
}
@property (nonatomic, readonly) NSInteger coffeeID;
@property (nonatomic, retain) NSInteger participant_Id;
@property (nonatomic, copy) NSString *question_Id;
@property (nonatomic, copy) NSString *answer_option;
@property (nonatomic, copy) NSString *answer_text;
@property (nonatomic, copy) NSString *update_date_time;
- (void)save_Local {
CereniaAppDelegate *appDelegate = (CereniaAppDelegate *)[[UIApplication sharedApplication] delegate];
Coffee *coffeeObj = [[Coffee alloc] initWithPrimaryKey:0];
coffeeObj.participant_Id=mynumber;
NSString*question="1";
coffeeObj.question_Id=question;
coffeeObj.answer_option=selectionAnswerOption;
coffeeObj.answer_text=professionTextField.text;
NSDate* date = [NSDate date];
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd HH:MM:SS"];
NSString* str = [formatter stringFromDate:date];
UPDATE_DATE_TIME=str;
coffeeObj.update_date_time=UPDATE_DATE_TIME;
//Add the object
[appDelegate addCoffee:coffeeObj];
}
Quand je suis affectation d'une valeur à participant_id il donne une erreur.
Vous devez vous connecter pour publier un commentaire.
NSInteger
n'est pas une classe, il est un type de base comme unint
oulong
. Sur iOSNSInteger
esttypedef
ed d'uneint
, sur OS X, il esttypedef
ed d'unlong
. Par conséquent, vous ne devriez pas essayer deretain
unNSInteger
. Vous devriez changer votre déclaration de propriété pour:Va de même pour vos
coffeeID
propriété.NSNumber
.NSInteger
etNSUInteger
sont des classes.