Objective-C property getter
- by Daniel
What is technically wrong with the following:
@property(nonatomic, assign) NSUInteger timestamp;
@property(nonatomic, readonly, getter = timestamp) NSUInteger startTime;
@property(nonatomic, assign) NSUInteger endTime;
I am sure I can find a better way to organise this, but this is what I ended up with at one point in my project and I noticed that accessing the startTime property always returned 0, even when the timestamp property was set to a correct timestamp.
It seems having set the getter of startTime to an existing property (timestamp), it is not forwarding the value of timestamp when I do:
event.startTime => 0
event.timestamp => 1340920893
All these are timestamps by the way.
Just a reminder, I know the above should have happened in my project but I don't understand why accessing startTime doesn't forward onto timestamp property.
UPDATE
In my implementation I am synthesising all of these properties:
@synthesize timestamp, endTime, startTime;
Please check an example object to use that demonstrates this at my gist on GitHub: https://gist.github.com/3013951