में एनएसआईएनटेगर संपत्ति असाइन करना मेरे पास SQLite में एक तालिका है जो मैं उस तालिका में डेटा डालना चाहता हूं। तालिका में respondes_id, participant_id, answer_text, answer_option_update_date_time है। respondes_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];
}
जब मैं सहभागी_आईडी के लिए मूल्य आवंटित कर रहा हूं तो यह एक त्रुटि देता है।
धन्यवाद यह मेरे लिए काम करता है –
यदि आप इसे एक वस्तु होना चाहते हैं, तो आप इसे 'NSNumber' में लपेट सकते हैं। – QED
कोई समस्या नहीं है। लोगों के लिए 'एनएसआईएनटेगर' और 'एनएसयूइंटर' कक्षाएं सोचने के लिए यह एक आम भ्रम है। – mttrb