
Property 'managedObjectStore' not found on object of type'RKObjectManager *'
coding九月 29, 20151mins
iOS Restkit 经验错误
问题H2
使用Restkit时,访问RKObjectManger的managedObjectStore属性是提示
Property ‘managedObjectStore’ not found on object of type’RKObjectManager *’
原因H2
看了下RKObjectManger的头文件中关于managedObjectStore属性的定义是这样的
bash
#ifdef RKCoreDataIncluded/**A Core Data backed object store for persisting objects that have been fetched from the Web*/@property (nonatomic, strong) RKManagedObjectStore *managedObjectStore;/**An array of `RKFetchRequestBlock` blocks used to map `NSURL` objects into corresponding `NSFetchRequest` objects.When searched, the blocks are iterated in the reverse-order of their registration and the first block with a non-nil return value halts the search.*/@property (nonatomic, readonly) NSArray *fetchRequestBlocks;/**Adds the given `RKFetchRequestBlock` block to the manager.@param block A block object to be executed when constructing an `NSFetchRequest` object from a given `NSURL`. The block has a return type of `NSFetchRequest` and accepts a single `NSURL` argument.*/- (void)addFetchRequestBlock:(NSFetchRequest *(^)(NSURL *URL))block;#endif
同时这个宏变量是这样定义的
bash
#ifdef _COREDATADEFINES_H#if __has_include("RKCoreData.h")#define RKCoreDataIncluded#endif
_COREDATADEFINES_H这个宏是在CoreData的CoreDataDefines.h头文件中定义的
CoreDataDefines.h
bash
#ifndef _COREDATADEFINES_H#define _COREDATADEFINES_H
解决H2
需要在import Restkit,这样在importRKObjectManger.h时,才能正确定义宏以及属性。
bash
#include <CoreData/CoreData.h>
总结H2
OC中的头文件引入顺序非常重要,会影响到一些实际代码特别是一些宏的定义。
评论
新的评论
上一篇
gradle-tomcat-plugin 404
问题 执行gradle-tomcat-plugin的tomcatRun任务时,服务器正常启动,没有任何异常,输出的log也没有异常,但是访问时返回404页面 原因 gradle-tomcat-plugin部署应用时,插件会去查找 src/main/webapp 目录。如果没有找…
下一篇
Docker CI
Docker CI 构建私有 Docker Registry 启动 registry Insecure Registry 当尝试从配有配置TLS的Registry会报如下错 并且 官方文档 提到 While it’s highly recommended to secure y…
