Reputation: 6160
I know this could be a duplicated question, but also there are conflicting answers about it ! I'm little confused about that.. my problem is when I profile my app using the instruments to check the leaks .. its keep showing a leak at this method loadNibNamed:
.. so related to these questions :
1.Do I need to release IBOutlets when using loadNibNamed: method?
2.Using loadNibNamed leaves a memory leak
I found that some people said that you have to release the IBOutlets
even if you don't implement the accessor methods ! and the others says that you shouldn't release these outlets since the iOS will take care about it , so please I need a correct answer based on professoinal experience since that will need me to do alot of work with my project.
Edit / For Example :
If this is my .h class file
@interface MenuViewEPub : UIViewController<ePubBrightnessDelegate,FontDelegate,PagesSlidePreviewerDelegate,ePubExpandSearchBarDelegate,EnviromentAudioChooserDelegate,UIPopoverControllerDelegate,WEPopoverControllerDelegate> {
IBOutlet UIView *upperMenu;
IBOutlet UIView *lowerMenu;
IBOutlet ePubBrightnessButton *brightnessButton;
IBOutlet FontButton *fontButton;
IBOutlet UIBarButtonItem *backButtonTitle;
IBOutlet UIBarButtonItem *indexButtonTitle;
IBOutlet UIBarButtonItem *annotationButtonTitle;
UIView *readerView;
IBOutlet ePubExpandSearchBar *searchBar;
id<MenuViewControllerDelegat>delegate;
IBOutlet PagesSlidePreviewer *pageSilder;
IBOutlet UIButton *arEnButton;
int pageNumber;
int chapterIndex;
int chtCount;
BOOL isLandscape;
UIPopoverController *lastPopover;
}
@property (nonatomic, assign) id<MenuViewControllerDelegat>delegate;
@property (nonatomic, retain) ePubExpandSearchBar *searchBar;
@property (nonatomic, assign) int chtCount;
@property (nonatomic, assign) int pageNumber;
@property (nonatomic, assign) int chapterIndex;
@property (nonatomic, assign) BOOL isRotate;
- (IBAction)tocButtonPressed:(id)sender;
- (IBAction)AnnotationsPressed:(id)sender;
- (IBAction)BackPressed:(id)sender;
- (IBAction)rtfPressed:(id)sender;
- (IBAction) audioPressed:(UIButton*)sender;
- (IBAction) tipsPressed:(UIButton*)sender;
- (void) showMenuInView :(UIView*) destview;
- (void) createViews;
- (void) hideMenu : (BOOL)animate;
- (void) changePageNumber:(int)pageNum;
@end
Do I have to release any outlet except the searchBar ?
Upvotes: 0
Views: 700
Reputation: 60498
Unless you are using ARC, you should release any retained subviews in the viewDidUnload
method. This would include subviews that are "injected" via IBOutlets. You would usually also include anything you might have created yourself in the viewDidLoad
method.
Upvotes: 1