How do I create delegates in Objective-C?

后端 未结 19 2607
一整个雨季
一整个雨季 2020-11-21 04:48

I know how delegates work, and I know how I can use them.

But how do I create them?

19条回答
  •  青春惊慌失措
    2020-11-21 05:23

    ViewController.h

    @protocol NameDelegate 
    
    -(void)delegateMEthod: (ArgType) arg;
    
    @end
    
    @property id  delegate;
    

    ViewController.m

    [self.delegate delegateMEthod: argument];
    

    MainViewController.m

    ViewController viewController = [ViewController new];
    viewController.delegate = self;
    

    Method:

    -(void)delegateMEthod: (ArgType) arg{
    }
    

提交回复
热议问题