开发者

Do init* functions retain what is passed to them?

开发者 https://www.devze.com 2022-12-24 01:44 出处:网络
I init a navigation controller with: UINavigationController *navController = [[UINavigationControlle开发者_StackOverflow中文版r alloc] initWithRootViewController:firstViewController];

I init a navigation controller with:

UINavigationController *navController = [[UINavigationControlle开发者_StackOverflow中文版r alloc] initWithRootViewController:firstViewController];

I wonder if the navigation controller retains firstViewController or that I need to keep it alive. When I release firstViewController, the navigation controller still works. That seems wrong.

Clarifications?


If it needs to keep it around it will retain it. So yeah, you'll be safe to release it if you don't need it anymore. It's not just initWhatever methods that have this behaviour - it's the standard operation of the whole memory management model.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号