Implement own setter or use KVO?

后端 未结 3 1059
臣服心动
臣服心动 2021-02-07 22:22

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){
           


        
3条回答
  •  梦谈多话
    2021-02-07 23:04

    The first snippet is the way to go, if you’re interested in changes in the same object. You only need to use the second if you are interested in changes to other objects, using it to observe self is overkill.

提交回复
热议问题