iOS-代理模式

XXXXXX.h

@protocol XXXXXXDelegate

- (void)sendSth:(NSString *)sth;

@end

@interface  XXXXXViewController : BaseViewController

@property (nonatomic , assign) id delegate;

@end

/*——————————————————————————————*/

XXXXXX.m

if (self.delegate && [self.delegate respondsToSelector:@selector(sendSth:)]) {

[self.delegate sendSth:something];

}



作用类

XXXXXX *xxx =[ [XXXXXX alloc] init];

xxx.delegate = self;


- (void)sendSth:(NSString *)sth

{

self.something = sth;

}

你可能感兴趣的:(iOS-代理模式)