November 2013
Beginner
325 pages
9h 47m
English
The system can automatically inform the observer if you use the accessor method to set the property. What if you, for some reason, choose not to use the accessor? You can explicitly let the system know that you are changing a property. Change your BNRLogger.m so that it does not use the accessor to set lastName:
- (void)updateLastTime:(NSTimer *)t
{
NSDate *now = [NSDate date];
_lastTime = now;
NSLog(@"Just set time to %@", self.lastTimeString);
}
Build and run the program. Notice that the Observer never gets told that _lastTime has changed.
To fix this, explicitly tell the system before and after you change the property:
- (void)updateLastTime:(NSTimer *)t
{
NSDate *now = [NSDate date];
Read now
Unlock full access