我是Core Data的新手,因此我不确定我是否犯了错误.我从REST API下载了一些数据,并成功将JSON响应保存到磁盘.我正在尝试处理数据并使用Core Data持久保存数据.
NSLog(@"inserted objects: %@", [managedObjectContext insertedObjects]);
[managedObjectContext performBlockAndWait:^{
NSError *error = nil;
if (![managedObjectContext save:&error]) {
NSLog(@"Unable to save context for class %@", className);
} else {
NSLog(@"saved all records!");
}
}];
Run Code Online (Sandbox Code Playgroud)
我已成功处理JSON并将其添加到NSManagedObjectContext.在第一行中,它显示我已成功尝试插入2个对象.
inserted objects: {(
<User: 0xa259af0> (entity: User; id: 0xa259b70 <x-coredata:///User/t44BB97D0-C4B4-4BA6-BD25-13CEFDAE665F3> ; data: {
email = "vishnu@vishnuprem.com";
experience = "2013-07-20";
"first_name" = Vishnu;
id = 2;
"job_title" = Developer;
"last_name" = Prem;
location = "";
"phone_number" = "+6590091516";
"profile_pic" …Run Code Online (Sandbox Code Playgroud)