Edit: The error messages that I am trying to figure out are on the right side of the code listed as comments!!!
Xcode keeps trying to suggest alternatives and refusing to let me build. The 3 are listed in comment tags on the right side of the code. What do they mean? I am very new to using core data and really hoping to see what I am doing wrong, just using username as an example (as I know I shouldn't be doing so)!
- (IBAction)saveData:(id)sender {
NSManagedObjectContext *cxt = [self managedObjectContext]; //instance method managedObjectContext not found
NSManagedObject *newContacts = [NSEntityDescription insertNewObjectForEntityForName:@"Contacts" inManagedObjectContext:cxt];
[newContacts setValue:self.username.text forKey:@"username"]; //insert NSManagedObjectModel instead of NSManagedObject...claims that it is undeclared?
username.text = @"";
NSManagedObject *newContacts = [NSEntityDescription insertNewObjectForEntityForName:@"Contacts" inManagedObjectContext:cxt]; //trying to replace NSEntityDescription with KSecAttrDescription...claims that it is undeclared
[newContacts setValue:self.password.text forKey:@"password"];
password.text = @"";
NSError *err;
if (![cxt save:&err]) {
NSLog(@"An error has occured: %@", [err localizedDescription]); //Instance Method -save not found
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…