作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
初始化 Restkit 时,我在运行时遇到此断言失败:
2011-11-09 08:00:50.817 myapp[32572:207] application:didFinishLaunchingWithOptions:
2011-11-09 08:00:50.820 myapp[32572:207] D app:myappAppDelegate.m:179 Initializing Restkit...
2011-11-09 08:00:50.889 myapp[32572:207] D restkit.network.queue:RKRequestQueue.m:214 Queue <RKRequestQueue: 0x742bde0> has been unsuspended
2011-11-09 08:00:50.889 myapp[32572:207] D restkit.network.queue:RKRequestQueue.m:48 Shared queue initialized: <RKRequestQueue: 0x742bde0>
2011-11-09 08:00:50.890 myapp[32572:207] D restkit.network.queue:RKRequestQueue.m:207 Queue <RKRequestQueue: 0x742bde0> has been suspended
2011-11-09 08:00:50.890 myapp[32572:207] D restkit.network:RKClient.m:250 Base URL changed for client <RKClient: 0x7136a00>, suspending main queue until reachability to host 'localhost' can be determined
2011-11-09 08:00:50.973 myapp[32572:207] D app:myappAppDelegate.m:190 Begining object mapping...
2011-11-09 08:00:50.974 myapp[32572:207] *** Assertion failure in -[RKManagedObjectMapping initWithEntity:], /Users/alex/Development/myapp/Libraries/RestKit/Code/CoreData/RKManagedObjectMapping.m:32
sharedlibrary apply-load-rules all
// RestKit
#import <RestKit/RestKit.h>
#import <RestKit/CoreData/CoreData.h>
#import <RestKit/Support/JSON/JSONKit/RKJSONParserJSONKit.h>
#import "DBManagedObjectCache.h"
#import "DBUser.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
...
RKLogDebug(@"Initializing Restkit...");
RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURL:@"http://localhost:8888"];
//objectManager.router = [[RKDynamicRouter new] autorelease];
//manager.router = router;
objectManager.objectStore = [[[RKManagedObjectStore alloc] initWithStoreFilename:@"mydb.sqlite"] autorelease];
objectManager.objectStore.managedObjectCache = [[DBManagedObjectCache new] autorelease];
RKLogDebug(@"Begining object mapping...");
RKManagedObjectMapping* userMapping = [RKManagedObjectMapping mappingForClass:[DBUser class]];
RKLogDebug(@"Begining object mapping... 1");
userMapping.primaryKeyAttribute = @"userID";
userMapping.setDefaultValueForMissingAttributes = YES; // clear out any missing attributes (token on logout)
...
}
- (id)initWithEntity:(NSEntityDescription*)entity {
NSAssert(entity, @"Cannot initialize an RKManagedObjectMapping without an entity. Maybe you want RKObjectMapping instead?");
...
最佳答案
感谢 tegbains 对 restkit 的介绍,真正解决问题的是在 DataModel.xcdatamodel 中创建实体 DBUser :)
关于objective-c - 休息套件 "*** Assertion failure in -[RKManagedObjectMapping initWithEntity:]",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8065659/
我有以下 JSON 结构: { "users": [ { "user_id":"000228D2-CB0D-4019-ADF9-66FE163E0BBC", "
初始化 Restkit 时,我在运行时遇到此断言失败: 2011-11-09 08:00:50.817 myapp[32572:207] application:didFinishLaunchingW
我是一名优秀的程序员,十分优秀!