Why use a copy for block properties?

Why should block properties be declared as copies?

typedef void(^Thunk)(void);
@property (nonatomic, copy) Thunk block;

Why do I need a copy of a block object?

+3
source share
3 answers

Because the stack creates a block literal and will be destroyed when the function exits. When saving a block around it, you need to copy it.

+3
source

, , , . , , , , , . , .

+2

. :

  • objc_objects

... , .

+1

All Articles