mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-01-12 22:51:50 +08:00
Eliminate remaining use of keyed subscript access
This commit is contained in:
@@ -48,7 +48,7 @@ static NSString *RKCacheKeyForEntityWithAttributeValues(NSEntityDescription *ent
|
||||
NSArray *sortedAttributes = [[attributeValues allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
|
||||
NSMutableArray *sortedValues = [NSMutableArray arrayWithCapacity:[sortedAttributes count]];
|
||||
[sortedAttributes enumerateObjectsUsingBlock:^(NSString *attributeName, NSUInteger idx, BOOL *stop) {
|
||||
id cacheKeyValue = RKCacheKeyValueForEntityAttributeWithValue(entity, attributeName, attributeValues[attributeName]);
|
||||
id cacheKeyValue = RKCacheKeyValueForEntityAttributeWithValue(entity, attributeName, [attributeValues objectForKey:attributeName]);
|
||||
[sortedValues addObject:cacheKeyValue];
|
||||
}];
|
||||
|
||||
|
||||
@@ -242,7 +242,7 @@ static BOOL entityIdentificationInferenceEnabled = YES;
|
||||
NSMutableDictionary *attributes = [NSMutableDictionary dictionaryWithCapacity:[connectionSpecifier count]];
|
||||
for (NSString *sourceAttribute in connectionSpecifier) {
|
||||
NSString *destinationAttribute = [self transformSourceKeyPath:sourceAttribute];
|
||||
attributes[sourceAttribute] = destinationAttribute;
|
||||
[attributes setObject:destinationAttribute forKey:sourceAttribute];
|
||||
}
|
||||
connection = [[RKConnectionDescription alloc] initWithRelationship:relationship attributes:attributes];
|
||||
} else if ([connectionSpecifier isKindOfClass:[NSDictionary class]]) {
|
||||
|
||||
@@ -43,7 +43,7 @@ static NSDictionary *RKConnectionAttributeValuesWithObject(RKConnectionDescripti
|
||||
NSCAssert([connection isForeignKeyConnection], @"Only valid for a foreign key connection");
|
||||
NSMutableDictionary *destinationEntityAttributeValues = [NSMutableDictionary dictionaryWithCapacity:[connection.attributes count]];
|
||||
for (NSString *sourceAttribute in connection.attributes) {
|
||||
NSString *destinationAttribute = connection.attributes[sourceAttribute];
|
||||
NSString *destinationAttribute = [connection.attributes objectForKey:sourceAttribute];
|
||||
id sourceValue = [managedObject valueForKey:sourceAttribute];
|
||||
[destinationEntityAttributeValues setValue:sourceValue forKey:destinationAttribute];
|
||||
}
|
||||
|
||||
@@ -40,13 +40,15 @@ NSArray *RKArrayOfFetchRequestFromBlocksWithURL(NSArray *fetchRequestBlocks, NSU
|
||||
return fetchRequests;
|
||||
}
|
||||
|
||||
// RKManagedObjectOrArrayOfManagedObjectsInContext(id managedObjectOrArrayOfManagedObjects, NSManagedObjectContext *managedObjectContext);
|
||||
// Find the key paths for all entity mappings in the graph whose parent objects are not other managed objects
|
||||
|
||||
static NSDictionary *RKDictionaryOfManagedObjectsInContextFromDictionaryOfManagedObjects(NSDictionary *dictionaryOfManagedObjects, NSManagedObjectContext *managedObjectContext)
|
||||
{
|
||||
NSMutableDictionary *newDictionary = [[NSMutableDictionary alloc] initWithCapacity:[dictionaryOfManagedObjects count]];
|
||||
[managedObjectContext performBlockAndWait:^{
|
||||
NSError *error = nil;
|
||||
for (NSString *key in dictionaryOfManagedObjects) {
|
||||
id value = dictionaryOfManagedObjects[key];
|
||||
__block NSError *error = nil;
|
||||
[dictionaryOfManagedObjects enumerateKeysAndObjectsUsingBlock:^(NSString *key, id value, BOOL *stop) {
|
||||
if ([value isKindOfClass:[NSArray class]]) {
|
||||
NSMutableArray *newValue = [[NSMutableArray alloc] initWithCapacity:[value count]];
|
||||
for (__strong id object in value) {
|
||||
@@ -64,7 +66,7 @@ static NSDictionary *RKDictionaryOfManagedObjectsInContextFromDictionaryOfManage
|
||||
}
|
||||
|
||||
[newDictionary setValue:value forKey:key];
|
||||
}
|
||||
}];
|
||||
}];
|
||||
|
||||
return newDictionary;
|
||||
|
||||
Reference in New Issue
Block a user