- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在将 Restkit .20 集成到一个现有的 iOS 应用程序中,并(看似)正确设置所有内容并使用我的初始模型。创建新对象、存储它们、检索它们等等,都在工作。在我使用 restkit/code 数据部署这个新版本的应用程序之前,我想测试一个简单的轻量级迁移以确保 future 的更改能够正常工作,但是当我这样做时,我总是会收到“找不到源存储模型”错误创建我的持久存储。这是我的 reskit 设置代码:
- (void)setupRestKit {
// set up the managed object and set the serialization type to json
_objectManager = [RKObjectManager managerWithBaseURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", [self getServerBase]]]];
[_objectManager setRequestSerializationMIMEType:RKMIMETypeJSON];
// create our managed object models and store, and set the store on the manager
NSManagedObjectModel *managedObjectModel = [NSManagedObjectModel mergedModelFromBundles:nil];
RKManagedObjectStore *managedObjectStore = [[RKManagedObjectStore alloc] initWithManagedObjectModel:managedObjectModel];
_objectManager.managedObjectStore = managedObjectStore;
<...all of my entity mapping and response descriptor code is here...>
// tell our store to create a persistent store coordinator
[managedObjectStore createPersistentStoreCoordinator];
// create the path to the database
NSString *storePath = [RKApplicationDataDirectory() stringByAppendingPathComponent:@"<path>.sqlite"];
NSError *error;
// these options allow for lightweight migration
NSDictionary *options = @{
NSMigratePersistentStoresAutomaticallyOption: @(YES),
NSInferMappingModelAutomaticallyOption: @(YES)
};
// create our sqlite persistent store with this path and options
NSPersistentStore *persistentStore = [managedObjectStore addSQLitePersistentStoreAtPath:storePath fromSeedDatabaseAtPath:nil withConfiguration:nil options:options error:&error];
NSAssert(persistentStore, @"Failed to add persistent store with error: %@", error);
// tell our store to create the object contexts
[managedObjectStore createManagedObjectContexts];
// Configure a managed object cache to ensure we do not create duplicate objects
managedObjectStore.managedObjectCache = [[RKInMemoryManagedObjectCache alloc] initWithManagedObjectContext:managedObjectStore.persistentStoreManagedObjectContext];
为了创建我的数据模型的新版本,我选择了当前模型并转到“编辑器”->“添加模型版本”。复制原始模型后,我向我的一个对象添加了一个字符串属性“test”,通过选择新数据模型并点击 command-n 并选择 NSManagedObject 子类从我的模型中生成新对象。然后我选择了新模型和所有对象并创建了它们。
在创建新模型、更改其中一个对象属性并基于此模型重新创建所有对象后,我更改了文件检查器中的模型版本以匹配我创建的新模型,然后运行项目 -我收到上述错误的地方。有人知道/看到我做错了什么吗?
最佳答案
Tom 是正确的 - 我的问题是:
NSManagedObjectModel *managedObjectModel = [NSManagedObjectModel mergedModelFromBundles:nil];
正如我所说,我的项目非常大,所以我没有意识到其中已经存在数据模型,所以我在设置 Restkit 时创建的托管对象模型试图合并所有它们一起捆绑在一起,这显然行不通。我的解决方案是更改代码,以便我仅使用我用于 Restkit 的特定模型创建托管对象模型,如下所示:
NSString *path = [[NSBundle mainBundle] pathForResource:@"Model" ofType:@"momd"];
NSURL *url = [NSURL fileURLWithPath:path];
NSManagedObjectModel *managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:url];
现在,如果我想对模型进行更改,我单击我当前使用的模型的最新版本,转到编辑器 -> 添加模型版本,然后将新模型建立在先前模型的基础上。对模型中的对象进行更改后,我将最新模型设为文件检查器中“模型版本”下的“当前”模型,当我运行该项目时,它运行良好!
关于ios - Core Data和Restkit简单轻量级迁移报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20888925/
我使用 RestKit 与 REST api 进行交互。对于某些操作,例如 HTTP PUT/POST/DELETE,我只关心响应状态代码(200 或 500 等),而不关心响应数据,即使 API 确
我在客户端和服务器端都有一个这样的响应对象: 客户端: //BaseResponse.h @interface BaseResponse : NSObject{ NSString *code;
我正在尝试将 RestKit 0.20 集成到我的项目中,例如,我使用 google rss 阅读器作为示例项目。 这是对 Xml 的响应 / /类别> & 这是我必须从中获取数据的 Xml。 RKO
我很难使用 CocoaPods 将 RestKit 安装到我的项目中。我收到未找到的错误。 我的 Pods.xcconfig 看起来像这样: GCC_PREPROCESSOR_DEFINITIONS
大多数 RESTful API 都会路由对资源的访问,例如 Rabbit 对象,如下所示: GET /rabbits <--- GET all rabbits.
问题 在 iOS 上完成 Restkit 的安装说明后,我收到 Apple Mach-o 链接器错误: 我的流程 我尝试按照此处的 Restkit 安装说明进行操作:https://github.co
我完全按照此处找到的这些步骤操作: http://www.raywenderlich.com/13097/intro-to-restkit-tutorial 但是....我得到了错误: 这可能是什么原
我正在尝试使用 RestKit 调用需要基本身份验证的端点。 RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[JSNCateg
我想用RestKit ,但我已经使用 Realm.io而不是 CoreData。 是否可以在 Realm.io 之上使用 RestKit? 最佳答案 你当然可以。从 RestKit 取回对象后: //
我没有找到任何方法来设置 restkit 0.20.0 的超时间隔。 任何人都可以帮助增加超时间隔。 谢谢 最佳答案 子类 RKHTTPRequestOperation 和实现方法 - (NSURLR
我正在尝试实现 RESTKit 0.20 操作队列,我在博客上读到 NSOperationQueue 也可用于创建操作队列。我想使用 RestKit 操作队列的 native 方法。 任何人都可以发布
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 8年前关闭。 Improve thi
我在这里做的事情很奇怪吗? 我的类别得到下载和映射, 产品也像日志记录所说的那样被下载和映射, 但是我的产品在每个分类下都是空的,谢谢! { "productsCategories" : [
我尝试了几乎所有的解决方案,但都不适合我。我在 Xcode 6 上收到此错误。我也更新了 cocoa pod ,也更新了 pod 文件。 安装更新后,我在下面添加了几行: [!] From now o
我正在尝试使用 Jenkins-CI 自动构建一个使用 Restkit 的 iOS 项目,显然,restkit 作为一个项目驻留在主项目中。该项目使用 XCode-IDE 成功构建。 但是当我使用 x
我在 Xcode 6.1 中开发项目。它工作正常,突然提示错误“未找到 Restkit/Restkit.h 文件”。从 $ 更改Architectures 后出现错误(ARCHS_STANDARD_3
我按照 github 上的说明进行操作页面但有问题(肯定是我:P)但是,您知道在 Xcode4 RestKit 中集成/使用的任何好的教程吗? 谢谢! 最佳答案 从此链接下载最新版本 http://r
我在尝试让 RestKit 构建和工作时遇到了麻烦。我收到可怕的“词法或预处理器问题:未找到 RestKit/RestKit.h 文件”消息。我使用 Xcode 4.2,我的项目适用于 iOS。 早些
RKObjectManager *manager = [RKObjectManager managerWithBaseURL:[NSURL URLWithString:BASE_URL]]; PPPS
有没有办法使用对象管理器访问请求的成功块中的响应数据? [objectManager postObject:[User class] path:@"/users" parameters:nil suc
我是一名优秀的程序员,十分优秀!