The purpose of attributesForRepresentation is to delete keys and values of representation except attributes of entity. So the mutableKeys should minusSet [entity attributesByName] instead of [entity propertiesByName]. The propertiesByName includes relationship of entity.
typo in attributesForRepresentation
The code right after (between lines 214 and 217) already removes all representation relationships, except for [NSNull null] relationships (correct my thinking, if I'm wrong here, please!). Your change would strengthen this method by making sure no pesky NSNull relation gets returned in the resulting dictionary. Thumbs up from me for this commit 👍
Dang, that typo again? I swear, I've probably gotten that wrong more than I got it right. Thanks for the pull request.