In short, when the property value changing, I have to update some logic in my code, for example:
- (void)setProp:(NSString *)theProp
{
if (prop != theProp){
[prop release];
prop = [theProp copy];
[self myLogic];
}
}
or:
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context
{
if ([keyPath isEqualToString:@"prop"]){
[self myLogic];
}
}
Which is the best way, and WHY?
EDIT: I prefect the second way, because I don't know what the compiler will generate @synthesize
directive for me, I choose to believe the compiler is more smarter than my owe setter implementation, hence I will not break something.