我是 iOS 新手。谁能告诉我如何将我的 BO 与 Core Data 映射,以便我可以在我的项目中重用映射。这是我的代码
- (void) saveData
{
CoredataAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
NSManagedObjectContext *context = [appDelegate managedObjectContext];
NSManagedObject *newContact;
newContact = [NSEntityDescription insertNewObjectForEntityForName:@"Person" inManagedObjectContext:context];
[newContact setValue:firstName.text forKey:@"firstName"];
[newContact setValue:lastName.text forKey:@"lastName"];
[newContact setValue:driverLicenceno.text forKey:@"driverLicenceNumber"];
[newContact setValue:state.text forKey:@"state"];
[newContact setValue:phoneNO.text forKey:@"phoneNumber"];
[newContact setValue:injuryStatus.text forKey:@"injuryStatus"];
[newContact setValue:emailAddress.text forKey:@"emailAddress"];
NSLog(@"fName%@",firstName.text);
firstName.text = @"";
NSLog(@"fName%@",firstName.text);
lastName.text = @"";
driverLicenceno.text = @"";
state.text = @"";
phoneNO.text = @"";
injuryStatus.text = @"";
emailAddress.text = @"";
NSError *error;
[context save:&error];
status.text = @"Person saved";
}
除了这个之外,还有其他方法可以将我的 BO 与 coredata 映射吗?