'+ entityForName:nil不是合法的NSManagedObjectContext参数,用于搜索实体名称'Next''

时间:2015-12-09 08:26:22

标签: ios

- (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(@">>>>>>>>>>>>>");



}

1 个答案:

答案 0 :(得分:0)

$message = getRequestURI();

此行为您提供NSManagedObjectContext *context = [self managedObjectContext]; 而不是托管对象上下文。该错误消息表示您无法使用nil作为nil方法的managedObjectContext参数。

您的问题出现在代码的其他位置 - entityForName是如何设置的?