Last active
August 29, 2015 14:06
-
-
Save objectiveSee/6c62db7ba7d6e9c0b988 to your computer and use it in GitHub Desktop.
From Apple: https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/Blocks/Articles/bxUsing.html. You only need to make a copy when you expect the block to be used after destruction of the scope within which it was declared. Copying moves a block to the heap.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__weak EAFriendsListContacts *weakSelf = self; | |
phoneVerification.dismissBlock = ^(BOOL success, NSString *phoneNumber, NSString *verificationCode){ | |
[button setEnabled:YES withSpinner:NO]; | |
if (success) { | |
[[EAEffectManager sharedEffectManager] startEffect:EAEffectTypeConfettiApplause]; | |
[weakSelf _refreshContactData]; | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@property (nonatomic, copy) void (^dismissBlock)(BOOL success, NSString *phoneNumber, NSString *verificationCode); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Follow up question: I have been using
strong
instead ofcopy
in many many similar situations. Why has this never been a crash or issue?