Skip to content

Commit

Permalink
Attempt to fix a strange crashing bug caused by accessing self.entity…
Browse files Browse the repository at this point in the history
….relationshipsByName, which is a specialised NSDictionary subclass with fixed keys.

To workaround, make a copy in a standard NSDictionary.
  • Loading branch information
drewmccormack committed Sep 26, 2013
1 parent 0cedc81 commit f1dceb2
Showing 1 changed file with 7 additions and 3 deletions.
Expand Up @@ -62,14 +62,16 @@ - (void)createSyncChangesForChangedProperties
NSDictionary *changedValues = [self changedValues];

NSSet *propertyNamesToBeIgnored = [[self class] keysForWhichSyncChangesWillNotBeCreated];
NSDictionary *relationshipsByName = [[NSDictionary alloc] initWithDictionary:[[self entity] relationshipsByName]];
NSDictionary *attributesByName = [[NSDictionary alloc] initWithDictionary:[[self entity] attributesByName]];
for( NSString *eachPropertyName in changedValues ) {
if (propertyNamesToBeIgnored != nil && [propertyNamesToBeIgnored containsObject:eachPropertyName]) {
TICDSLog(TICDSLogVerbosityManagedObjectOutput, @"Not creating a change for %@.%@", [self class], eachPropertyName);
continue;
}
NSRelationshipDescription *relationship = [[[self entity] relationshipsByName] objectForKey:eachPropertyName];
NSAttributeDescription *attribute = [[[self entity] attributesByName] objectForKey:eachPropertyName];

NSRelationshipDescription *relationship = [relationshipsByName objectForKey:eachPropertyName];
NSAttributeDescription *attribute = [attributesByName objectForKey:eachPropertyName];
if ( relationship && !relationship.isTransient ) {
[self createSyncChangeIfApplicableForRelationship:relationship];
}
Expand All @@ -81,6 +83,8 @@ - (void)createSyncChangesForChangedProperties
[syncChange setChangedAttributes:eachValue];
}
}
[relationshipsByName release];
[attributesByName release];
}

#pragma mark -
Expand Down

0 comments on commit f1dceb2

Please sign in to comment.