
@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]; } 当我为participant_ID分配值时,它会给出错误.
解决方法 NSInteger不是类,它是一个类似int或long的基本类型.在iOS上,NSInteger的类型定义为int,在OS X上,它的类型定义为long.因此,您不应该尝试保留NSInteger.您应该将您的财产声明更改为:@property (nonatomic,assign) NSInteger participant_ID;
您的coffeeID属性也是如此.
总结以上是内存溢出为你收集整理的在iPhone App中分配NSInteger属性全部内容,希望文章能够帮你解决在iPhone App中分配NSInteger属性所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)