replace all the if (managedObjectKey == nil) to if (managedObjectKey == nil || [managedObjectKey isEqual:[NSNull null]]) will resolve the crash issue.
replace all the
if (managedObjectKey == nil)
to
if (managedObjectKey == nil || [managedObjectKey isEqual:[NSNull null]])
will resolve the crash issue.