【问题标题】:RestKit with CoreData crashes带有 CoreData 的 RestKit 崩溃
【发布时间】:2012-02-25 21:23:01
【问题描述】:

我是 CoreData 的新手,刚开始使用 RestKit。我正在尝试使用 CoreData 创建一个 Restkit 项目。但是我收到了这个运行时错误:

+[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;

任何帮助/cmets 将不胜感激。

谢谢 维克

【问题讨论】:

    标签: core-data ios5 restkit


    【解决方案1】:

    你能用失败的实际断言更新你的帖子吗?

    如果_objectManager 没有objectStore 集,您将不能使用RKManagedObjectMapping。此行已在您发布的代码中注释掉。

    【讨论】:

      猜你喜欢
      • 2015-01-28
      • 2015-11-19
      • 1970-01-01
      • 1970-01-01
      • 2015-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-14
      相关资源
      最近更新 更多