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
}
}
Solved it! However, it was from a previous answer for this question who removed them self, so I’m giving the credit to that unknown person. If anybody has this error in the future, click on you core data.xcdatamoldeld, then click on the Editor section on your menu bar (of your desktop), then click set NSManagedObject Subclass and add them. It should work then.