Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are NSManagedObject and NSEntityDescription separate classes?

It seems that an NSEntityDescription object describes data and an NSManagedObject object contains the corresponding data. If you have a normal NSObject subclass, the description of the data and the actual data are in the same place, aren't they. Well at least the description is in the class and the data is in the object. You can think of an object as having a description of the kind of variables it contains.

Why then does Core Data separate the class which describes the data and the class which contains the data? Is it to do with faulting?

like image 736
nevan king Avatar asked Mar 30 '11 07:03

nevan king


1 Answers

If you have a normal NSObject subclass, the description of the data and the actual data are in the same place, aren't they.

No. The class is the description of the object and the instance is the object (including its data.

Why then does Core Data separate the class which describes the data and the class which contains the data? Is it to do with faulting?

No it is because the description of the model is intrinsically different to the instantiation of data that complies with the model. This is a standard thing in computing e.g. for a SQL database, the description of the data (the DDL) is not the data (an actual database). With XML the description (schema or DTD) is not the actual XML data.

like image 195
JeremyP Avatar answered Oct 01 '22 00:10

JeremyP