Simple KVO example

前端 未结 3 2056
陌清茗
陌清茗 2021-02-05 02:01

I am trying to do simple KVO example, but I am having problems.

This is my *.m file:

#import \"KVO_ViewController.h\"

@interface KVO_ViewController (         


        
3条回答
  •  无人共我
    2021-02-05 02:15

    KVO works with setter and getter and in incNumber you are directly accessing iVar so instead of that use self.number

    - (IBAction)incNumber:(id)sender
    {
        self.number++;
        NSLog(@"%d", self.number);
    }
    

提交回复
热议问题