编辑:我试图找出的错误消息位于代码的右侧,列为注释!!!
Xcode 不断尝试提出替代方案并拒绝让我构建。这 3 个列在代码右侧的注释标记中。他们的意思是什么?我对使用核心数据非常陌生,真的希望看看我做错了什么,只是以用户名为例(我知道我不应该这样做)!
- (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
}
}