iPhone – Why do I need to use the original accessor method in the core data item?

Why do I need to use raw accessor methods in Core Data projects?

I am reading about core data, please note the following:

By default, Core Data dynamically
creates efficient public and primitive
get and set accessor methods for
modeled properties (attributes and
relationships) of managed object
classes…

For example, given an entity with an
attribute firstName, Core Data
automatically generates firstName,
setFirstName:, primitiveFirstName, and
setPrimitiveFirstName:.

I’m not sure what the original accessor method is What? How do they work? When & why do I need to use them on normal accessor methods?

Thank you

In ordinary classes, you usually don’t use the original Accessors, but Core Data will use them often. The most common scenario: you write custom accessors (perform maintenance, create default objects, handle transient packaging of persistent properties, etc.), but want to use Core Data’s optimized storage. If The optimized accessor is a normal accessor, then your custom accessor will prevent it from being available, but you only need to use the original accessor.

Also, the default accessor you get from Xcode Includes methods for adding or removing objects from a many-to-many relationship. If these methods use normal accessors, the normal accessors will trigger change notifications for the entire set. Instead, they use the original accessors and create themselves for the part they are changing Notification of changes.

The most important thing is that the original accessor is the only way to get optimized storage. Without them, you will have to use the instance variables suggested by Apple.

p>

Why do I need to use raw accessor methods in Core Data projects?

I am reading about core data, please note the following:

By default, Core Data dynamically
creates efficient public and primitive
get and set accessor methods for
modeled properties (attributes and
relationships) of managed object
classes…

For example, given an entity with an
attribute firstName, Core Data
automatically generates firstName,
setFirstName:, primitiveFirstName, and
setPrimitiveFirstName:.

I’m not sure what the original accessor method is What? How do they work? When & why do I need to use them on normal accessor methods?

Thank you

In ordinary classes, you usually don’t use primitive accessors, but Core Data will use them often. Common scenario: You write a custom accessor (perform maintenance, create default objects, handle transient packaging of persistent properties, etc.), but you want to use Core Data’s optimized storage. If the optimized accessor is a normal accessor, then your A custom accessor will prevent it from being available, but you only need to use the original accessor.

In addition, the default accessor you get from Xcode includes adding or removing objects from a many-to-many relationship Methods. If these methods use normal accessors, the normal accessors will trigger change notifications for the entire set. Instead, they use the original accessors and create their own change notifications for the parts they are changing.

The important thing is that primitive accessors are the only way to get optimized storage. Without them, you would have to use the instance variables suggested by Apple.

Leave a Comment

Your email address will not be published.