在自定义类中设置块属性 [英] Setting up a block property in custom class
本文介绍了在自定义类中设置块属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个公开imageBlock
属性的第三方API.我是Blocks的新手-我应该如何在课堂上设置此Block?
I have a third party API that exposes an imageBlock
property. I am new to Blocks - how should I set this Block in my class?
@property (copy) NSString *(^imageBlock)(NSString *key, NSString *value, BOOL *send);
推荐答案
您的语法是正确的,但是,出于理智和可读性考虑,我建议使用typedef
为此Block签名创建另一个名称:
Your syntax is correct, however, for sanity and readability I would recommend a typedef
to create another name for this Block signature:
// MyClass.h
typedef NSString * (^ImageBlock)(NSString * key, NSString * value, BOOL * send);
您的财产声明将变为:
@property (copy) ImageBlock imageBlock;
和导入此标头的任何其他文件都可以看到typedef
,同样使用它来提高可读性.
and any other file which imports this header can see the typedef
, likewise using it to increase readability.
这篇关于在自定义类中设置块属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文