本文介绍了我可以使用Objective-C块作为属性吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用标准属性语法将块作为属性?
Is it possible to have blocks as properties using the standard property syntax?
ARC 是否有任何更改?
推荐答案
@property (nonatomic, copy) void (^simpleBlock)(void);
@property (nonatomic, copy) BOOL (^blockWithParamter)(NSString *input);
如果您要在几个地方重复相同的块,请使用def
If you are going to be repeating the same block in several places use a type def
typedef void(^MyCompletionBlock)(BOOL success, NSError *error);
@property (nonatomic) MyCompletionBlock completion;
这篇关于我可以使用Objective-C块作为属性吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!