Declared Properties and assigning values with self

Posted by Shaun Budhram on Stack Overflow See other posts from Stack Overflow or by Shaun Budhram
Published on 2010-06-16T22:05:07Z Indexed on 2010/06/16 22:22 UTC
Read the original article Hit count: 160

Filed under:

I understand how declared properties work - I just need a clarification on when Objective C is using the accessor method vs. when it is not.

Say I have a property declared using retain:

@property (nonatomic, retain) NSDate *date;

... and later... @synthesize date

If I say: date = x

Is that calling the accessor method? Or is it just setting the variable?

self.date = x

This seems to call the accessor method (I think but I'm not sure, since it seems like the retain count is increasing).

Can anyone clarify this issue? I'm curious because i have some variables that seem to become invalid before I need them (and I have to specifically call retain), and I suspect this is why.

© Stack Overflow or respective owner

Related posts about objective-c