1

プロジェクトに追加するためのRestKitドキュメントのすべての手順に従いましたが、アプリを起動しようとすると、次の行で停止しますapplication:application didFinishLaunchingWithOptions::

entityMapping.identificationAttributes = @[@"_id"];

その前のコードは次のとおりです。

NSURL *modelURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"MyModel" ofType:@"momd"]];
NSManagedObjectModel *managedObjectModel = [[[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL] mutableCopy];
RKManagedObjectStore *managedObjectStore = [[RKManagedObjectStore alloc] initWithManagedObjectModel:managedObjectModel];

// Init the Core Data stack
[managedObjectStore createPersistentStoreCoordinator];

NSPersistentStore __unused *persistentStore = [managedObjectStore addInMemoryPersistentStore:&error];
NSAssert(persistentStore, @"Faild to add persistent store: %@", error);

[managedObjectStore createManagedObjectContexts];

// Set the default shared store instance
[RKManagedObjectStore setDefaultStore:managedObjectStore];

// Configure the object manager
RKObjectManager *objectManager = [RKObjectManager managerWithBaseURL:[NSURL URLWithString:@"http://localhost:9090"]];
objectManager.managedObjectStore = managedObjectStore;

[RKObjectManager setSharedManager:objectManager];

RKEntityMapping *entityMapping = [RKEntityMapping mappingForEntityForName:@"Pool" inManagedObjectStore:managedObjectStore];
[entityMapping addAttributeMappingsFromDictionary:@{
 @"id":         @"_id",
 @"about_url":  @"aboutURL",
 @"closed":     @"closed",
 @"created_on": @"createdOn"
}];
entityMapping.identificationAttributes = @[@"_id"];

if (!attribute) [NSException raise:NSInvalidArgumentException format:@"Invalid attribute '%@': no attribute was found for the given name in the '%@' entity.", attributeOrName, [entity name]];の一部である行 100 ()の RKEntityMapping.m で例外がスローされRKArrayOfAttributesForEntityFromAttributesOrNamesます。

「プール」と表示されていpo [entity name]ても、.xcdatamodeld にプール エンティティがあります。

このエラーの原因を他にどこで探すことができますか?

4

1 に答える 1

1

エンティティにidプロパティを追加します。注:プロパティに名前を付けても問題ありませんが、Objective-C のキーワードではない名前に変更することをお勧めします。Pool
id

于 2013-05-14T03:56:13.577 に答える