如何在保存上下文对象之前限制添加到数据库?

时间:2014-06-20 08:39:11

标签: ios

在保存上下文之前,

insertNewObjectForEntityForName方法在iOS中将对象插入数据库以获取核心数据。如何在保存上下文对象之前限制它添加到数据库?

请帮助解决这个问题.....

这是我的代码.... - (BOOL)addTeam :(团队*)团队{

BOOL result = NO;
NSLog(@"inside dao %@ context obj %@",team.team_Name,context);
//here i am getting newly created object also before saving the context...
NSLog(@"Array of team before saving context :%@",[self getAllTeams]);
//  3
NSError *error;
if (![context save:&error]) {
    NSLog(@"Whoops, couldn't save: %@", [error localizedDescription]);
    result = NO;
}
NSLog(@"Team saved");
result = YES;
return result;

}

0 个答案:

没有答案