Question

I have some code in an app that creates a CoreData managed object. In this code, I use the following line to set a property:

theAuthor.authorID = 1;

The property is declared like this in the managed object header:

@property (nonatomic) uint32_t authorID;

In iOS 5 it works fine, but when I debug in iOS 4.3, I get this error:

Property 'authorID' is a scalar type on class 'Author'. Cannot generate a setter method for it.

Why am I getting this error in 4.3, but not in 5? Should I be avoiding scalar properties? I came to Obj-C from C, so I prefer to work with scalars when I can, as it feels more optimised.

Would I be better implementing the getters and setters or changing my code to use NSInteger or NSNumber instead?

Was it helpful?

Solution

See here for information on using scalar attributes in core data. (By the way, NSInteger is a scalar). Listing 3 is the particular one you are interested in. Basically, you need to write your own accessor for it, but it's not difficult.

As of iOS5, you can use scalar properties in core data. This can be achieved by ticking the appropriate box when generating your managed object subclasses from the data model.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top