iOS 将方法作为参数或属性传递

1.作为属性的声明

@property(nonatomic,assign)SEL startSelect;

2.作为方法的参数

- (void)setHudView:(UIView*)hudview withShow:(SEL)showHUD hidden:(SEL)hiddenHUD;

3.调用传递的方法

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
    if ([self.hud respondsToSelector:self.startSelect]) {
        [self.hud performSelector:self.startSelect];
    }
#pragma clang diagnostic pop

你可能感兴趣的:(iOS 将方法作为参数或属性传递)