Last active
May 16, 2016 20:26
-
-
Save 3lvis/fca1fa6449f554ed6ff33c0e00b136b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let remoteItems = localPrimaryKey | |
let localRelationship = self.valueForKey(relationship.name) | |
let localItems = localRelationship?.valueForKey(entity.sync_localPrimaryKey()) as? NSArray ?? NSArray() | |
let intersection = NSMutableSet(array: remoteItems as [AnyObject]) | |
intersection.intersectSet(Set(arrayLiteral: localItems)) | |
let updatedItems = intersection.allObjects | |
let deletedItems = localItems.mutableCopy() | |
deletedItems.removeObjectsInArray(remoteItems as [AnyObject]) | |
let insertedItems = remoteItems.mutableCopy() | |
insertedItems.removeObjectsInArray(localItems as [AnyObject]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment