Suppose I have a class with readonly property.
@interface MyClass
@property (readonly) NSInteger MonitorMe;
@end
Now suppose the point of this property is to track changes in another property inside another object, and when the property is "observed", it returns the derived value by checking the value from another external object.
@implementation
@synthesize MonitorMe;
-(NSInteger) getMonitorMe
{
return globalStaticClass.OtherNSInteger;
}
... Inits and Methods ...
@end
Now suppose some where I instantiate an object MyClassand I want to add a KVO observer to the property MonitorMe.
@implementation AnotherClass.m
@synthesize instanceOfMyClass;
-(id)init
{
...
instanceOfMyMethod = [MyClass init];
[MyClass addObserver: self
forKeyPath: @"MonitorMe"
options: NSKeyValuObservingOptionNew
context: nil];
...
}
, , MonitorMe , globalStaticClass.OtherNSInteger? , , , ?
, voodoo.
, , ARC , iOS. , OS X iOS , , iOS, , .
, . , / globalStaticClass.OtherNSInteger readonly, MonitorMe. , , readonly .