Я сопоставляю два класса объектов с помощью RestKit.Когда я делаю любой из них сам по себе, это прекрасно работает.Но когда я вызову их вместе, произойдет сбой в строке 449
в RKObjectMappingOperation.m
,
[destinationSet setSet:destinationObject];
с ошибкой "EXC_BAD_ACCESS"
.
Вот два моих метода сопоставления:
- (RKObjectLoader *)saves
{
// Create an object manager and connect core data's persistent store to it
RKObjectManager *objectManager = [RKObjectManager sharedManager];
RKManagedObjectStore* objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:@"Db.sqlite"];
objectManager.objectStore = objectStore;
// Define our author mapping for saved places
RKManagedObjectMapping *authorMapping = [RKManagedObjectMapping mappingForEntityWithName:@"Person"];
[authorMapping mapAttributes:@"uid", nil];
// Define our place mapping
RKManagedObjectMapping *placeMapping = [RKManagedObjectMapping mappingForEntityWithName:@"Place"];
[placeMapping mapAttributes:@"uid",@"name",@"address", nil];
// Now, connect the two via a save
RKManagedObjectMapping *saveMapping = [RKManagedObjectMapping mappingForEntityWithName:@"Save"];
[saveMapping mapAttributes:@"uid", @"timestamp", nil];
[saveMapping mapKeyPath:@"place" toRelationship:@"place" withMapping:placeMapping];
[saveMapping mapKeyPath:@"author" toRelationship:@"author" withMapping:authorMapping];
// We expect to find the place entity inside of a dictionary keyed "saves"
[objectManager.mappingProvider setMapping:saveMapping forKeyPath:@"saves"];
// Prepare our object loader to load and map objects from remote server, and send
RKObjectLoader *objectLoader = [objectManager objectLoaderWithResourcePath:@"places/saves" delegate:self];
objectLoader.method = RKRequestMethodGET;
[objectLoader send];
return objectLoader;
}
- (RKObjectLoader *)recommends
{
// Create an object manager and connect core data's persistent store to it
RKObjectManager *objectManager = [RKObjectManager sharedManager];
RKManagedObjectStore* objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:@"Db.sqlite"];
objectManager.objectStore = objectStore;
// Define our author mapping for recommended places
RKManagedObjectMapping *authorMapping = [RKManagedObjectMapping mappingForEntityWithName:@"Person"];
[authorMapping mapAttributes:@"uid", nil];
// Define our place mapping
RKManagedObjectMapping *placeMapping = [RKManagedObjectMapping mappingForEntityWithName:@"Place"];
[placeMapping mapAttributes:@"uid",@"name",@"address", nil];
// Now, connect the two via a recommend
RKManagedObjectMapping *recommendMapping = [RKManagedObjectMapping mappingForEntityWithName:@"Recommend"];
[recommendMapping mapAttributes:@"uid", @"timestamp", nil];
[recommendMapping mapKeyPath:@"place" toRelationship:@"place" withMapping:placeMapping];
[recommendMapping mapKeyPath:@"author" toRelationship:@"author" withMapping:authorMapping];
// We expect to find the place entity inside of a dictionary keyed "recommends"
[objectManager.mappingProvider setMapping:recommendMapping forKeyPath:@"recommends"];
// Prepare our object loader to load and map objects from remote server, and send
RKObjectLoader *objectLoader = [objectManager objectLoaderWithResourcePath:@"places/recommends" delegate:self];
objectLoader.method = RKRequestMethodGET;
[objectLoader send];
return objectLoader;
}
Когда я звоню одному или другому, это работает.Когда я звоню обоим,
[self saves];
[self recommends];
Вылетает.Есть идеи почему?