iOS   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了在iPhone App中分配NSInteger属性大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

在Sqlite中有一个表我想在该表中插入数据.该表有respond_id,participant_id,answer_text,answer_option_update_date_time. responses_id和participant_id是整数.当我将任何事物分配给participant_id时,它会给出错误,对象无法设置为属性. @interface Coffee : NSObject@H_618_5@
我在sqlite中有一个表我想在该表中插入数据.该表有respond_id,participant_id,answer_text,answer_option_update_date_time. responses_id和participant_id是整数.当我将任何事物分配给participant_id时,它会给出错误,对象无法设置为属性.

@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属性所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。