I’m developing an iOS 4 application.
I have this ViewController:
@interface BlogViewController : UIViewController
{
...
UIView* tabBar;
}
@property (nonatomic, retain) IBOutlet UIView* tabBar;
And its implementation:
And its implementation:
@implementation BlogViewController
@synthesize tabBar;
- (void) dealloc
{
...
[super dealloc];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
self.tabBar = nil;
}
My question if I have a IBOutlet property, is it necessary to declare the UIView like this?
@interface BlogViewController : UIViewController
{
...
UIView* tabBar;
}
If I do it, Do I need to release it on dealloc?
- (void) dealloc
{
...
[tabBar release];
[super dealloc];
}
In order: no you don’t need to declare the instance variable, yes you do need to release the object. You may consider using Automatic Reference Counting to get the memory management aspect correct for you.