Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

allow multi-level key paths for relationship mappedKeyName #280

Closed
wants to merge 1 commit into from

2 participants

@cmezak

I had the impression from Saul's blog post that mappedKeyName could be a full key path, not just a key, but valueForKey: is being used in MR_setRelationships:forKeysWithObject:withBlock:. Switched to valueForKeyPath:.

This allows you to actually use a multi-level key path for mappedKeyName for a relationship.

@cmezak cmezak using valueForKeyPath: instead of valueForKey for pulling relationshi…
…p object data from import data

This allows you to actually use a multi-level key path for mappedKeyName for a relationship.
f55ab4c
@cmezak cmezak closed this
@casademora
Owner

Not sure Matt Long wrote that blog post ;)

@cmezak

Brain fail. Sorry, Saul, and thanks for the post! :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 15, 2012
  1. @cmezak

    using valueForKeyPath: instead of valueForKey for pulling relationshi…

    cmezak authored
    …p object data from import data
    
    This allows you to actually use a multi-level key path for mappedKeyName for a relationship.
This page is out of date. Refresh to see the latest.
View
2  MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalDataImport.m
@@ -137,7 +137,7 @@ - (void) MR_setRelationships:(NSDictionary *)relationships forKeysWithObject:(id
NSRelationshipDescription *relationshipInfo = [relationships valueForKey:relationshipName];
NSString *lookupKey = [[relationshipInfo userInfo] valueForKey:kMagicalRecordImportRelationshipMapKey] ?: relationshipName;
- id relatedObjectData = [relationshipData valueForKey:lookupKey];
+ id relatedObjectData = [relationshipData valueForKeyPath:lookupKey];
if (relatedObjectData == nil || [relatedObjectData isEqual:[NSNull null]])
{
Something went wrong with that request. Please try again.