Fixed possible crash caused when fetching managed object ID from string

- Checking for nil and ensuring the stringRepresentation object is an NSString prior to trying to translate it to an NSManagedObjectID