Re: ARC query
Re: ARC query
- Subject: Re: ARC query
- From: Mike Abdullah <email@hidden>
- Date: Wed, 07 Jan 2015 21:11:42 +0000
> On 7 Jan 2015, at 20:55, Sean McBride <email@hidden> wrote:
>
> On Wed, 7 Jan 2015 12:02:16 -0600, Ken Thomases said:
>
>> Short answer: yes, the alert is retained.
>
> Meaning that one must use the weak/strong dance pattern like this?
>
> NSAlert *alert = [NSAlert new];
> alert.alertStyle = NSWarningAlertStyle;
> alert.messageText = @“Do not touch!";
> __weak NSAlert* weakAlert = alert;
> [alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse returnCode) {
> NSAlert *strongAlert = weakAlert;
> [strongAlert orderOut:self];
> }];
>
> I miss garbage collection. None of that was necessary. I still haven't got my head around dealing with this under ARC…
No, no dancing necessary. The completion block is only fired the once. After that it’s discarded, breaking the retain cycle.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden