what is happening/why is it necessary/what is the purpose of setting up that relationship within the entity?
It isn't necessary, it's just an example and an easy way to create a hierarchy for a master-detail interface with a minimal Core Data model
assuming it's related, why might the author declare an NSManagedObject as a rootObject?
It's a simple way to create a 'master' object. Usually the 'master' or 'root' object would be defined by the only object in the context whose parent == nil
.
None of the core data demos I've seen actually declare NSManagedObjects.
That doesn't really mean anything. Apps will often temporarily hold a pointer to a managed object instance. Indeed, a fetched request controller can hold multiple pointers to objects at any one time.
For example, the master/detail template in xCode just declares, which gives you a basic core data project
Apple examples aren't the best. That template also has the app delegate owning the Core Data stack and thats a terrible decision...
Aside:
The predicate can use the relationship better by using the relationship 'backwards'. i.e. rather than load the children relationship and check the contents it should reference the parent and check for equality:
@"parent == %@", selectedParent