RMUniversalAlert icon indicating copy to clipboard operation
RMUniversalAlert copied to clipboard

__weak RMUniversalAlert *weakAlert = alert 的bug

Open cdoky opened this issue 8 years ago • 6 comments

alert.alertController = [UIAlertController showAlertInViewController:viewController
                                                           withTitle:title message:message
                                                   cancelButtonTitle:cancelButtonTitle
                                              destructiveButtonTitle:destructiveButtonTitle
                                                   otherButtonTitles:otherButtonTitles
                                                            tapBlock:^(UIAlertController *controller, UIAlertAction *action, NSInteger buttonIndex){
                                                                if (tapBlock) {
                                                                    //the var ‘weakAlert’ is nil
                                                                    tapBlock(alert, buttonIndex);
                                                                    alert = nil;
                                                                }
                                                            }];

i think you can do this: image

cdoky avatar Oct 31 '16 02:10 cdoky

Hi - what version of iOS are you running this on and seeing the fault?

ryanmaxwell avatar Nov 01 '16 04:11 ryanmaxwell

can you try version 0.8.1 and let me know if it's better? thanks

ryanmaxwell avatar Nov 01 '16 04:11 ryanmaxwell

hi, i use ios 9.2 and ios 10. i'm use version 0.8.1 find this bug. i found the alert object in tapBlock is nil by debug. i think, if user cancel the alert, the alert object retain will -1, so, the alert object retain is 0.

cdoky avatar Nov 01 '16 06:11 cdoky

@ryanmaxwell Hi, in 0.8.1 issue of "alert is nil" is obv fixed ..but you brought back retain cycle. alert retains link of alertcontroller -> which holds link to alert via tapBlock. Right now dealloc never called. You have to do at least this "if (tapBlock) { tapBlock(alert, buttonIndex); } alert = nil;"

alexburkhay avatar Nov 03 '16 00:11 alexburkhay

@alexburkhay thanks if you can submit a PR that fixes the retain cycles and nil alert that would be appreciated.

ryanmaxwell avatar Nov 03 '16 03:11 ryanmaxwell

@iphilcc @ryanmaxwell @alexburkhay I fix the issues in the pr . Has anyone can review my code?

nianran avatar Jan 15 '17 04:01 nianran