iOS协议使用

协议A

#import 


@protocol ProtocolADelegate 

- (void)say;

@end

实现地方

#import 

@interface ViewController : UIViewController


@end


#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    

    // Do any additional setup after loading the view, typically from a nib.
}


-(void)say{
    NSLog(@"hello");
}

@end

调用触发

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    
    
    NSMutableArray > * array = [@[[[ViewController alloc]init]] mutableCopy];
    
    id  module = array.firstObject;
    
    
    
    [module say];
    
    return YES;
}

你可能感兴趣的:(iOS协议使用)