tags:

views:

16

answers:

1

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.

A: 

date = x; is setting the instance variable directly and bypassing the accessor methods.

self.date = x; is the same thing as [self setDate:x];, and is using the accessor methods.

Dave DeLong
Thanks - just what I was looking for.
Shaun Budhram