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

时间:2016-12-06 09:33:10

标签: ios objective-c iphone core-data

我正在使用XIB并尝试将数据插入核心数据,同时我收到通知,并且我在以下方法中执行此操作。

(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(
UIBackgroundFetchResult))completionHandler
{
    [arr_message addObject:data];
    NSMutableArray *arr_insert_data = [[NSMutableArray alloc]init];
   _context=[self managedObjectContext];
   [arr_insert_data addObject:local_data];
   [mainViewController insertDiscusioninLocalDB:arr_message];
}

-(void)insertDiscusioninLocalDB :(NSMutableArray*)arr_msg
{
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Discusion_data" inManagedObjectContext:app.context];// BREAKS HERE
    NSFetchRequest *request = [[NSFetchRequest alloc]init];
    NSError *error = nil;
    [request setEntity:entity];
}

0 个答案:

没有答案