pointer memory management misunderstanding w/ objective-c -


I'm using the iPhone SDK 3.0, but I think it's how things work in W / C & A The general misunderstanding is, (Bool) animated {NSArray * items = [NSArray arrayWithOjbects: (zero) viewWillAppear - memory management

I have overridden the method like the @implementation MyViewController viewWillAppear: . Search button, self Trash, zero]; [Self. Bottombar Set ITEMS: Animated Items: Yes]; } // Other stuff ... @end

When I switch off the above view controller and switch back try everything works correctly.

But, my reference to "release" to the original pointer is "item" because I think a reference for NSArray is now organized by bottomBar. . But when I try to switch this off (see the code below) and switch away from the UIViewController, I get a memory management error (- [CFArray count]: Message deallocated example sent for 0xd5f530)

 < Code> - (zero) viewWillAppear: (bool) animated {NSArray * items = [NSArray arrayWithOjbects: self.searchButton, self.trashCan, zero]; [Self. Bottombar Set ITEMS: Animated Items: Yes]; [Item release]; }  

Do I need not release items in this case? Or am I doing something wrong? Evidently, empirical evidence points out that I should not leave "item", but it is not clear to me why this is the matter.

Thanks for any information / "hint"!

You do not need to release it because you never consider it. [Code: [NSArray arrayWithObjects: ...] gives an autoreleased object that you are not responsible for releasing it because it sent the autoreyz message when coming back from the system. All you have to do is leave! (If you had used [[NSArray alloc] initWithObjects: ...] you had to do it.)


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -