Hi all,
I have this piece of code:
UIWindow _window = [UIWindow alloc initWithFrame: http://UIScreen mainScreen].bounds;
_mainViewController = [MainViewController alloc] init;
_window addSubview: _mainViewController.view;
where _mainViewController is subclass of UIViewController.
If I check the reference count of "_mainViewController" after asigning its "view" to "_window", the value returned is "2". Why can "addSubview" message increase the reference count of "_mainViewController"? Shouldn´t "_window" just retain its view instead of the whole object?
Finally, when I try to release "_mainViewController", there reference count never get to 0 even if I release "_window" and "removeFromSuperview" its view.
Why does it behave like this?
Any idea about how I can release "_mainViewController"?
Thanks in advance
I have this piece of code:
UIWindow _window = [UIWindow alloc initWithFrame: http://UIScreen mainScreen].bounds;
_mainViewController = [MainViewController alloc] init;
_window addSubview: _mainViewController.view;
where _mainViewController is subclass of UIViewController.
If I check the reference count of "_mainViewController" after asigning its "view" to "_window", the value returned is "2". Why can "addSubview" message increase the reference count of "_mainViewController"? Shouldn´t "_window" just retain its view instead of the whole object?
Finally, when I try to release "_mainViewController", there reference count never get to 0 even if I release "_window" and "removeFromSuperview" its view.
Why does it behave like this?
Any idea about how I can release "_mainViewController"?
Thanks in advance