Abhinav
Abhinav

Reputation: 38162

Setting up a block property in custom class

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);

Upvotes: 0

Views: 488

Answers (1)

jscs
jscs

Reputation: 64022

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);

Your property declaration then becomes:

@property (copy) ImageBlock imageBlock;

and any other file which imports this header can see the typedef, likewise using it to increase readability.

Upvotes: 4

Related Questions