I have this in my interface:
@property (nonatomic, weak) NSTimeInterval *timeStamp;
Which my logic told me, I need a time stamp object, that only is going to be used by this class within the context of its instantiation, so “weak” seemed to be logical to me– but XCode tells me “property with ‘weak’ attribute must be of object type”… If I just do:
@property (nonatomic) NSTimeInterval *timeStamp;
Then the error goes away, but I am not sure I understand why…
The problem is that
NSTimeIntervalis a value type — it’s an alias fordouble, essentially (check NSDate.h for the typedef). Theweakattribute only applies to objects that have a retain count (that is, anything that descends fromNSObjectorNSProxy).As such, storing a pointer to
NSTimeIntervalis probably a mistake on your part. You will most likely never receive a pointer to anNSTimeIntervalunless you’re expected to write to a given address as an output to a function (probably a callback in such a case). That said, I’m not aware of any functions withNSTimeInterval *as a return type nor any that pass the same to a callback.