Can I pass a block as a @selector with Objective-C?

前端 未结 9 560
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-30 17:04

Is it possible to pass an Objective-C block for the @selector argument in a UIButton? i.e., Is there any way to get the following to work?

9条回答
  •  感动是毒
    2020-11-30 18:04

    The library BlocksKit on Github (also available as a CocoaPod) has this feature built-in.

    Take a look at the header file for UIControl+BlocksKit.h. They've implemented Dave DeLong's idea so you don't have to. Some documentation is here.

提交回复
热议问题