mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-23 04:20:21 +08:00
Fixes a crash in RKObjectMappingProvider where objectMappingsForClass is called after some dynamic mappings have been registered in the provider. Fixes #342. Thanks to @bjornjonsson
This commit is contained in:
@@ -66,12 +66,14 @@
|
||||
- (NSArray*)objectMappingsForClass:(Class)theClass {
|
||||
NSMutableArray* mappings = [NSMutableArray array];
|
||||
NSArray* mappingsToSearch = [[NSArray arrayWithArray:_objectMappings] arrayByAddingObjectsFromArray:[_mappingsByKeyPath allValues]];
|
||||
for (RKObjectMapping* objectMapping in mappingsToSearch) {
|
||||
if (objectMapping.objectClass == theClass && ![mappings containsObject:objectMapping]) {
|
||||
[mappings addObject:objectMapping];
|
||||
for (NSObject <RKObjectMappingDefinition> *candidateMapping in mappingsToSearch) {
|
||||
if (![candidateMapping respondsToSelector:@selector(objectClass)] || [mappings containsObject:candidateMapping])
|
||||
continue;
|
||||
Class mappedClass = [candidateMapping performSelector:@selector(objectClass)];
|
||||
if (mappedClass == theClass) {
|
||||
[mappings addObject:candidateMapping];
|
||||
}
|
||||
}
|
||||
|
||||
return [NSArray arrayWithArray:mappings];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user