我是iOS新手,我已经在核心数据中创建了实体
城市名称
距离
driverId
strainDescription
strainId
strainImage
strainName
strainTypeName
vendorBusinessName
vendorDriverEngagementId
vendorOverallRating
的数据类型NSstring,我正在尝试保存实体中的数据,期待输出
以下是我提取的JSON对象..
(
{
responseCode = 0;
},
(
{
cityName = “mumbai”;
distance = "2,412.3";
driverId = 00000000076;
strainDescription = "his is no creeper! ";
strainId = 00000000004;
strainImage = "www.d.net/dDocuments/StrainImages/Eyed Jamaican.jpg";
strainName = "Eyed Jamaican";
strainTypeName = "Body Car";
vendorBusinessName = businessName11;
vendorDriverEngagementId = 172;
vendorOverallRating = "4.8";
},
{
cityName = BLACKFOOT;
distance = "2,412.3";
driverId = 00000000073;
strainDescription = "pain relief, anxiety";
strainId = 00000000006;
strainImage = "www.d.net/dDocuments/StrainImages/Abra Cadabra.jpg";
strainName = "Abra Cada";
strainTypeName = "Body C";
vendorBusinessName = businessName15;
vendorDriverEngagementId = 174;
vendorOverallRating = "2.1";
},
) )
我正在尝试保存实体中的数据,期待输出
核心数据实体
cityName distance driverId strainDescription strainId ....。
孟买2,412.3 00000000076他不是爬行者! 00000000004BLACKFOOT 2,412.3 00000000073疼痛缓解0006 ...... ..
bd *entity = [NSEntityDescription insertNewObjectForEntityForName:@“db”inManagedObjectContext:self.managedObjectContext];
if (entity!=nil){
entity.cityName= [json valueForKey:@"cityName"];
entity.distance=[json valueForKey:@"distance"];
entity.distance=[json valueForKey:@“dr”iverID];
NSError *savingError = nil;
if ([self.managedObjectContext save:&savingError]){
}else{
NSLog(@"Failed to save the context. Error = %@", savingError);
NSLog(@"Successfully saved the context.");
}
}else{
NSLog(@"Failed to create the doobsterdb");
}
});
答案 0 :(得分:0)
json字符串,我想保存在核心数据实体
中(
{
responseCode = 0;
},
(
{
cityName = "mumbai";
distance = "2,412.3";
driverId = 00000000076;
strainDescription = "his is no creeper!";
strainId = 00000000002;
strainImage = "www.dbst.net/DoobsterDocuments/StrainImages/Eyed Jamaican.jpg";
strainName = "Eyed Jamaican";
strainTypeName = "Body Car";
vendorBusinessName = businessName11;
vendorDriverEngagementId = 172;
vendorOverallRating = "4.8";
},
{
cityName = BLACKFOOT;
distance = "2,412.3";
driverId = 00000000076;
strainDescription = "pain relief, anxiety";
strainId = 00000000006;
strainImage = "www.dbst.net/dbstDocuments/StrainImages/Abra Cadabra.jpg";
strainName = "Abra Cadabra";
strainTypeName = "Body Car";
vendorBusinessName = businessName15;
vendorDriverEngagementId = 174;
vendorOverallRating = "2.1";
},
)
)