I think that your expectation that presentViewController would retain a strong reference to the view controller is not right. I would put the release after the dismissal code has run. Now, you really don’t need the view controller.
Jonathan > On Dec 17, 2016, at 3:00 PM, [email protected] wrote: > > Send Cocoa-dev mailing list submissions to > [email protected] > > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.apple.com/mailman/listinfo/cocoa-dev > or, via email, send a message with subject or body 'help' to > [email protected] > > You can reach the person managing the list at > [email protected] > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Cocoa-dev digest..." > > > Today's Topics: > > 1. Releasing modal view controller properly (Andreas Falkenhahn) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sat, 17 Dec 2016 17:07:10 +0100 > From: Andreas Falkenhahn <[email protected]> > To: [email protected] > Subject: Releasing modal view controller properly > Message-ID: <[email protected]> > Content-Type: text/plain; charset=us-ascii > > I'm not using ARC so I need to take care of releasing objects manually. > I'm creating and presenting a modal UIViewController like this: > > MyViewController *vc = [[MyViewController alloc] init]; > > vc.modalPresentationStyle = UIModalPresentationFormSheet; > vc.preferredContentSize = CGRectMake(320, 320); > > [self presentViewController:vc animated:YES completion:nil] > [vc release]; > > When touching the modal view's close button my code does the following: > > [[self presentingViewController] dismissViewControllerAnimated:YES > completion:nil]; > > Unfortunately, the app crashes right after the modal view has completed > its transition animation. > > When I disable the line "[vc release]", I don't get any crashes and it > works fine. Can anybody explain why? I was expecting that > presentViewController() > retained the view controller so that it is safe for me to release it > right after making the call to presentViewController() because I don't > need it any longer but apparently, there's something wrong in my code > but I don't see it... > > -- > Best regards, > Andreas Falkenhahn mailto:[email protected] > > > > ------------------------------ > > _______________________________________________ > > Cocoa-dev mailing list ([email protected]) > > Do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins (at) lists.apple.com > > https://lists.apple.com/mailman/listinfo/cocoa-dev > > > End of Cocoa-dev Digest, Vol 13, Issue 518 > ******************************************
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list ([email protected]) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
