Re: Releasing modal view controller properly

2016-12-17 Thread Steve Mills
> On Dec 17, 2016, at 18:19, David Duncan  wrote:
> 
>   MyViewController *vc = [[MyViewController alloc] init];

What if you store that in a property of an object that persists as long as the 
window does? I'm guessing it's being deallocated before you think because of 
that release.

Steve via iPad


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com


Re: Releasing modal view controller properly

2016-12-17 Thread David Duncan

> On Dec 17, 2016, at 8:07 AM, Andreas Falkenhahn  
> 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:andr...@falkenhahn.com
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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/david.duncan%40apple.com
> 
> This email sent to david.dun...@apple.com

--
David Duncan


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Releasing modal view controller properly

2016-12-17 Thread Andreas Falkenhahn
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:andr...@falkenhahn.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com