I come from a heavy JavaScript-oriented background, and I switch to Objective-C as best I can. Naturally, I always came across the ability to use closing functions in my source code, for example:
@property (nonatomic, retain) void (^zoomCallback)(NSInteger width, NSInteger height, NSString *url);
However, every time I write this to Xcode, it warns me:
The stored property of the block does not copy the copy-use copy attribute instead
I realized that you no longer need to save things manually in Objective-C due to ARC, so I admittedly rather threw this warning. I assume the block refers to my closure function, so as far as I can interpret it, I am informed that the assignment to this variable is:
myObject.zoomCallback = someMethod;
Some method can also be saved, and therefore the owner of someMethod will continue to exist? Did I understand correctly?
What are the negative consequences of this? If I "copy" a block, do not let the owner of someMethod be destroyed, and therefore, in the closure method itself, whenever I refer to the "I", will it no longer exist? Don't I almost want to save the block if my closure method does not do something very trivial or something that does not refer to member variables or methods?
source share