Skip to content

Commit

Permalink
Fix unwrapped elements
Browse files Browse the repository at this point in the history
  • Loading branch information
3lvis committed Feb 1, 2016
1 parent 36ebced commit eed7204
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Source/NSManagedObject+Sync.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public extension NSManagedObject {
let inverseEntityName = relationship.inverseRelationship?.name
let inverseIsToMany = relationship.inverseRelationship?.toMany ?? false
let hasValidManyToManyRelationship = parent != nil && parentEntityName != nil && inverseIsToMany && parentEntityName! == childEntityName
if let children = dictionary[relationshipName] as? [[String : AnyObject]] {
if let relationshipName = relationshipName, children = dictionary[relationshipName] as? [[String : AnyObject]] {
var childPredicate: NSPredicate? = nil
if inverseIsToMany {
let entity = NSEntityDescription.entityForName(childEntityName, inManagedObjectContext: self.managedObjectContext!)!
Expand Down Expand Up @@ -131,11 +131,9 @@ public extension NSManagedObject {
let relationshipName = (relationshipKey != nil) ? relationshipKey : relationship.name.hyp_remoteString()
let entityName = relationship.destinationEntity!.name!
let entity = NSEntityDescription.entityForName(entityName, inManagedObjectContext: self.managedObjectContext!)!
if let filteredObjectDictionary = dictionary[relationshipName] as? NSDictionary {
var remoteID: AnyObject?
if let remoteKey = entity.sync_remoteKey() {
remoteID = filteredObjectDictionary[remoteKey]
}
if let relationshipName = relationshipName, filteredObjectDictionary = dictionary[relationshipName] as? NSDictionary {
let remoteKey = entity.sync_remoteKey()
let remoteID = filteredObjectDictionary[remoteKey]
let object = self.managedObjectContext!.sync_safeObject(entityName, remoteID: remoteID, parent: self, parentRelationshipName: relationship.name) ?? NSEntityDescription.insertNewObjectForEntityForName(entityName, inManagedObjectContext: self.managedObjectContext!)
object.sync_fillWithDictionary(filteredObjectDictionary as! [String : AnyObject], parent: self, dataStack: dataStack)
let currentRelationship = self.valueForKey(relationship.name)
Expand Down

0 comments on commit eed7204

Please sign in to comment.