在类型'RKObjectManager'的对象上找不到属性'managedObjectStore' [英] Property 'managedObjectStore' not found on object of type 'RKObjectManager'

查看:94
本文介绍了在类型'RKObjectManager'的对象上找不到属性'managedObjectStore'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用Restkit库的0.20.3版本.最近发生了一个错误,我无法解决.如下:

I've been attempting to work with version 0.20.3 of the Restkit library. Recently an error has occurred that I cannot figure out how to solve. It is the following:

在类型的对象上找不到属性"managedObjectStore" 'RKObjectManager *'

Property 'managedObjectStore' not found on object of type 'RKObjectManager *'

它发生在包含

objectManager.managedObjectStore = managedObjectStore;

下面列出了我的一小段代码,以帮助进行识别.我使用CocoaPods安装了所有必需的库,并且一切似乎都可以正确链接.

A small block of my code is listed below to help with identification. I used CocoaPods to install all the necessary libraries and everything seems to link properly.

#import "AppDelegate.h"
#import <RestKit/RestKit.h>
#import <RestKit/CoreData.h>
#import <CoreData/CoreData.h>
#import <RestKit/ObjectMapping.h>
#import "Temperature.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:    (NSDictionary *)launchOptions
{

    //let AFNetworking manage the activity indicator
    [AFNetworkActivityIndicatorManager sharedManager].enabled = YES;

    // Override point for customization after application launch.
    RKObjectManager *objectManager = [RKObjectManager managerWithBaseURL:[NSURL URLWithString:@"http://grid.no-ip.biz/grid"]];
    NSURL *modelURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Grideye" ofType:@"momd"]];

    //Initialize managed object store
    NSManagedObjectModel *managedObjectModel = [[[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL ] mutableCopy];
    RKManagedObjectStore *managedObjectStore = [[RKManagedObjectStore alloc] initWithManagedObjectModel:managedObjectModel];

    objectManager.managedObjectStore = managedObjectStore;

   // Setup our object mappings
   /**
   Mapping by entity. Here we are configuring a maping by targetting a Core Data entity with a specific
   name. This allows us to map back Sensor database objects directly onto NSManagedObject instances
   there is no backing model class
   */
   RKEntityMapping *sensorMapping = [RKEntityMapping mappingForEntityForName:@"SensorID" inManagedObjectStore:managedObjectStore];
   sensorMapping.identificationAttributes = @[ @"sensorID"];
   [sensorMapping addAttributeMappingsFromDictionary:@{
        @"sensorID" : @"sensorID",
        @"cellNum"  : @"cellNum",
        @"timeStamp": @"timeStamp",
        @"temp"     : @"temp"
        }];

   //Update date format so that we can parse Sensor dates properly
   [RKObjectMapping addDefaultDateFormatterForString:@"E MMM d HH:mm:ss Z y" inTimeZone:nil];

   // Register our mappings with the provider
   RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:sensorMapping method:RKRequestMethodGET pathPattern:@":grid" keyPath:nil statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];

感谢您可以提供的任何输入!

Thanks for whatever input you can provide!

推荐答案

从0.20.1升级到0.20.3时,我遇到了完全相同的问题.

I had exactly the same issue when upgrading from 0.20.1 to 0.20.3.

您需要做的是在导入RestKit之前先导入CoreData.

What you need to do is to import CoreData before importing RestKit.

#import <CoreData/CoreData.h>
#import <RestKit/RestKit.h>

正在工作.

但是

#import <RestKit/RestKit.h>
#import <CoreData/CoreData.h>

不起作用.

这篇关于在类型'RKObjectManager'的对象上找不到属性'managedObjectStore'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆