I don’t know if I’m using viewDidUnload properly. Should I release all stuff I declare in my .h file?
Here is how I’m doing it now:
@property (strong, nonatomic) Readability *wrapper;
@property (strong, nonatomic) ArticleModel *article;
@property (strong, nonatomic) Woho *wohoItem;
@property (strong, nonatomic) FeedItem *item;
@property (unsafe_unretained, nonatomic) IBOutlet UIScrollView *scrollView;
@property (strong, nonatomic) NSMutableArray *picturesArray;
@property (unsafe_unretained, nonatomic) IBOutlet UILabel *headTitleLabel;
and in viewDidUnload:
- (void)viewDidUnload
{
[self setHeadTitleLabel:nil];
[self setScrollView:nil];
self.picturesArray = nil;
self.item = nil;
self.article = nil;
self.wohoItem = nil;
self.wrapper = nil;
}
Is this the right thing to do?
Probably not, because my app crash on every memory warning.
Thanks!
When a low-memory warning occurs, the
UIViewControllerclass purges its views if it knows it can reload or recreate them again later. If this happens, it also calls theviewWillUnloadandviewDidUnloadmethods to give your code a chance to relinquish ownership of any objects that are associated with your view hierarchy, including objects loaded from the nib file, objects created in your viewDidLoad method, and objects created lazily at runtime and added to the view hierarchy.