- (IBAction)btnsv:(id)sender
{
NSManagedObjectContext *context = [self managedObjectContext];
search=NO;
obj= [NSEntityDescription insertNewObjectForEntityForName:@"Next" inManagedObjectContext:context];
[obj setValue:self.nm.text forKey:@"name"];
[obj setValue:self.db.text forKey:@"dob"];
[obj setValue:self.ct.text forKey:@"city"];
[obj setValue:self.st.text forKey:@"state"];
[obj setValue:self.pn.text forKey:@"phone"];
[obj setValue:self.pw.text forKey:@"pwd"];
NSError *error;
[context save:&error];
self.nm.text=@"";
self.db.text=@"";
self.ct.text=@"";
self.st.text=@"";
self.pn.text=@"";
self.pw.text=@"";
NSFetchRequest *req=[[NSFetchRequest alloc]init];
NSEntityDescription *entiyy=[NSEntityDescription entityForName:@"Next" inManagedObjectContext:context];
[req setEntity:entiyy];
NSError *errorjj;
[context save:&errorjj];
nxt=[context executeFetchRequest:req error:&errorjj];
NSLog(@">>>>>>>>>>>>>");
}
答案 0 :(得分:0)
$message = getRequestURI();
此行为您提供NSManagedObjectContext *context = [self managedObjectContext];
而不是托管对象上下文。该错误消息表示您无法使用nil
作为nil
方法的managedObjectContext
参数。
您的问题出现在代码的其他位置 - entityForName
是如何设置的?