Reputation: 1179
Can anyone verify my dealloc method is correct? Since my titleLabel and checkImageView are retained I am releasing them in dealloc. However, I am not releasing mainImageView, doneButton, and noteLabel, because they are not retained or alloced during the implementation.
@interface CheckMarkController : UIViewController <UIAlertViewDelegate> {
IBOutlet UIImageView *mainImageView;
IBOutlet UIButton *doneButton;
IBOutlet UILabel *noteLabel;
}
@property (nonatomic, retain) IBOutlet UILabel *titleLabel;
@property (nonatomic, retain) IBOutlet UIImageView *checkImageView;
@property (nonatomic, retain) Event *event;
@property (nonatomic, retain) Workout *workout;
@property (nonatomic, retain) NSManagedObjectContext *managedObjectContext;
@end
- (void)dealloc {
//props
[titleLabel release];
[checkImageView release];
[event release];
[workout release];
[managedObjectContext release];
[super dealloc];
Upvotes: 1
Views: 706
Reputation: 16540
If you connect these three items via Interface Builder you DO need to release them. Outlets are retained by default. KVC (Key Value Coding) is used to set outlets. This means that loadFromNib
will call setValue:withKey
for each outlet you have set. This uses the @property
and it's setter method, but if none are set (as is your case) it retains the object by default.
Upvotes: 4