协议A
#import <Foundation/Foundation.h>
@protocol ProtocolADelegate <NSObject>
- (void)say;
@end
实现地方
#import <UIKit/UIKit.h>
@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 <id<NSObject>> * array = [@[[[ViewController alloc]init]] mutableCopy];
id <ProtocolADelegate> module = array.firstObject;
[module say];
return YES;
}
网友评论