如何在Swift中使用Block?

时间:2015-05-22 10:02:00

标签: swift

我在目标C中使用块

typedef void (^RequestSuccessCallback)(WebRequestManager *request);
@property (nonatomic,copy) RequestSuccessCallback RequestSuccessBlock;

但是如何在swift中使用Block?

1 个答案:

答案 0 :(得分:2)

尝试这样的事情:

typealias RequestSuccessCallback = (WebRequestManager) -> Void
var requestSuccessBlock: RequestSuccessCallback

如果您更喜欢命名回调,则可能是这样的:

typealias RequestSuccessCallback = (manager: WebRequestManager) -> Void
var requestSuccessBlock: RequestSuccessCallback