2012-02-25 118 views
0

我是CoreData新手,剛開始使用RestKit。我正在嘗試使用CoreData創建Restkit項目。但我收到此運行時錯誤:Restartit與CoreData崩潰

斷言失敗+ NSManagedObject managedObjectContext]

任何想法,我做錯了什麼?

以下是我的代碼到目前爲止。至今我還沒有創建數據模型。

 _objectManager = [RKObjectManager objectManagerWithBaseURL:@"https://api.foursquare.com/v2/venues"]; 
    // _objectManager.objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:@"jiffAssignment.sqlite"]; 

    RKManagedObjectMapping *locationMapping = [RKManagedObjectMapping mappingForClass:[Location class]]; 
    [locationMapping mapKeyPath:@"address" toAttribute:@"address"]; 
    [locationMapping mapKeyPath:@"crossStreet" toAttribute:@"crossStreet"]; 
    [locationMapping mapKeyPath:@"city" toAttribute:@"city"]; 
    [locationMapping mapKeyPath:@"state" toAttribute:@"state"]; 
    [_objectManager.mappingProvider setMapping:locationMapping forKeyPath:@"location"]; 

    // RKObjectMapping *statisticsMapping = [RKManagedObjectMapping mappingForClass:[Statistics class]]; 
// [statisticsMapping mapAttributes:@"checkinsCount",@"usersCount", nil]; 


    NSLog(@"VenueListController Initialized"); 
    return self; 

任何幫助/意見將不勝感激。

感謝 維克

回答

0

你能更新失敗的實際斷言你的帖子?

如果_objectManager沒有設置objectStore,那麼您應該無法使用RKManagedObjectMapping。該行在您發佈的代碼中註釋掉。