2011-11-03 35 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

相關問題