2011-11-03 41 views
0

当我尝试将属性添加到我的实体时,我的应用程序会收到SIGABRT。当试图在实体中添加属性时SIGABRT。 iOs上的核心数据

NSManagedObjectContext *context=[[HistoryDataManager sharedInstance] mainObjectContext]; 
    NSEntityDescription * entityDescription = [NSEntityDescription entityForName:@"Request" inManagedObjectContext:context]; 
    Request *request=[[[Request alloc] initWithEntity:entityDescription insertIntoManagedObjectContext:context] autorelease]; 
    NSLog(@"request: %@", request); 
    request.requestText=string; 
    request.timeStamp=[NSDate date]; 
    [context insertObject:request]; 
    NSError * error; 
    if (![context save:&error]) { 
     NSLog(@"Saving error : %@", [error userInfo]); 
    } 

我有与名称请求和上下文=无实体,但我有SIGABRT消息每次在这个地方!

NSEntityDescription * entityDescription = [NSEntityDescription entityForName:@"Request" inManagedObjectContext:context]; 
+0

我们可以有完整的SIGABRT消息吗? – KIDdAe

+0

不知何故,在控制台中没有SIGABRT消息 – stalk

回答

0

最有可能context为零。传递一个零管理的对象上下文值通常会导致崩溃。在将它传递给方法之前,请确认您在context中有值。

检查实体名称。

+0

我在上下文中有价值,我绝对有实体名称请求 – stalk

-3

问题出在我的DataManager单例中,很抱歉浪费你的时间。

+2

你可以说你做了什么来解决它吗? – tomtaylor