small medium large xlarge

Back to: All Forums  Core Data
04 Jun 2010, 15:32
Cem Karan (2 posts)

Hi, I’m currently working my way through the book, and have a small question regarding the use of @property in PPRecipe on page 47 of the 1.0 printing of the book. The interface is as follows:

@interface PPRecipe : NSManagedObject {

@property (assign) NSString *desc; 
@property (assign) NSString *name; 
@property (assign) NSString *type; 
@property (assign) NSManagedObject *author; 
@property (assign) NSDate *lastUsed;

Why are all of the property attributes using assign? I thought that with objects we were always supposed to use retain, or run the risk of having our pointers when said objects go out of scope somewhere else. I know that this is probably of lesser risk for single-threaded code, but the final application I want to write is going to be heavily multi-threaded, so I need to make sure I’m doing everything 100% correctly (I know there is a multi-threaded section in the book, I just haven’t gotten there yet!)

Thanks for writing the book!

04 Jun 2010, 17:47
Marcus S. Zarra (284 posts)

Thank you for bringing that to my attention, those should be retain. However since we are using @@dynamic@ they will be retained within the superclass @NSManagedObject@. We are just “describing” them wrong.

If we were using @@synthesize@ then this would be a bigger (and more obvious) issue.

You must be logged in to comment