开发者

Why are NSManagedObject and NSEntityDescription separate classes?

开发者 https://www.devze.com 2023-02-20 13:02 出处:网络
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 ac

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 descrip开发者_如何学Ction 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号