2011-11-09 2 views
2

초기화 Restkit는 :Restkit "***에서 어설 션 실패 - [RKManagedObjectMapping initWithEntity :]"내가 런타임에이 어설 션 오류를 받고 있어요

// 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) 

... 
} 
:

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 

이 코드입니다

여기가 RKManagedObjectMapping.m에서 실패합니다.

- (id)initWithEntity:(NSEntityDescription*)entity { 
NSAssert(entity, @"Cannot initialize an RKManagedObjectMapping without an entity. Maybe you want RKObjectMapping instead?"); 
... 

아이디어가 있습니까? 감사 !!!! kky

답변

3

감사 tegbains 당 DataModel.xcdatamodel의 실체 dbuser에를 만드는대로 매핑 RKObjectMapping 및 관련 비 관리 오브젝트를 사용하는 것을 고려하고 객체한다 :

0

나는 CoreData를 사용하지 않는다고 생각합니다. 실제로 문제가 해결 무엇 restkit에 대한 소개,이 Tutorial