Dependent properties

What if you want to observe lastTimeString instead of lastTime? Try it. In main.m, start observing lastTimeString:

 ​ ​ ​ ​ ​ ​ ​ ​_​_​u​n​u​s​e​d​ ​B​N​R​O​b​s​e​r​v​e​r​ ​*​o​b​s​e​r​v​e​r​ ​=​ ​[​[​B​N​R​O​b​s​e​r​v​e​r​ ​a​l​l​o​c​]​ ​i​n​i​t​]​;​
 ​ ​ ​ ​ ​ ​ ​ ​[​l​o​g​g​e​r​ ​a​d​d​O​b​s​e​r​v​e​r​:​o​b​s​e​r​v​e​r​
 ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​f​o​r​K​e​y​P​a​t​h​:​@​"​l​a​s​t​T​i​m​e​S​t​r​i​n​g​"​
 ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​o​p​t​i​o​n​s​:​N​S​K​e​y​V​a​l​u​e​O​b​s​e​r​v​i​n​g​O​p​t​i​o​n​N​e​w​ ​|​ ​N​S​K​e​y​V​a​l​u​e​O​b​s​e​r​v​i​n​g​O​p​t​i​o​n​O​l​d​
 ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​c​o​n​t​e​x​t​:​n​i​l​]​;​

If you build and run the program, you will see that the notifications ...

Get Objective-C Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.