• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Releasing modal view controller properly
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Releasing modal view controller properly


  • Subject: Re: Releasing modal view controller properly
  • From: David Duncan <email@hidden>
  • Date: Sat, 17 Dec 2016 16:19:06 -0800

> On Dec 17, 2016, at 8:07 AM, Andreas Falkenhahn <email@hidden> wrote:
>
> 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…

The code you’ve presented is fine, so the issue is likely to be elsewhere.

>
> --
> Best regards,
> Andreas Falkenhahn                          mailto:email@hidden
>
> _______________________________________________
>
> 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

--
David Duncan


_______________________________________________

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


  • Follow-Ups:
    • Re: Releasing modal view controller properly
      • From: Andreas Falkenhahn <email@hidden>
    • Re: Releasing modal view controller properly
      • From: Steve Mills <email@hidden>
References: 
 >Releasing modal view controller properly (From: Andreas Falkenhahn <email@hidden>)

  • Prev by Date: Releasing modal view controller properly
  • Next by Date: Re: Releasing modal view controller properly
  • Previous by thread: Releasing modal view controller properly
  • Next by thread: Re: Releasing modal view controller properly
  • Index(es):
    • Date
    • Thread