开发者

Does UINavigationBar retain UINavigationItems pushed onto its stack?

Does UINavigationBar retain nav items pushed onto its stack? In other words, after doing this:

_myNavItem = [[UINavigationItem alloc]initWithTitle:@"Home"];
[self.navBar pushNavigationItem:_myNavItem animated:NO];

do I need to release _myNavItem with:

    [_myNavItem release];

in order to avoid a memory leak?

Also, h开发者_开发百科ow do I find out in general whether or not an object will be retained? Is it just a convention that any Objective C collection maintains ownership of all elements added to it?


The ADC UINavigationBar Class Reference mentions at the definition of the items property it is storing all UIViewControllers pushed onto the navigation stack with an NSArray.

Moving on to the NSArray Class Reference, it is stated that the default implementation of the NSArray class retains every object inserted into it and releases it when it is removed.

Putting these two things together it is safe to imply that UINavigationController retains all of its UIViewControllers when they are pushed onto the stack.


Yes, the UINavigationBar retains its UINavigationItems. Just like an NSArray or NSDictionary retains its objects, so does a UINavigationBar.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜