Issue of IBOutlet Collection Issue

I have an array for the IBOutlet collection

.h

@interface UpisiRezultat : UIViewController {
    NSArray *buttons;
}

@property (nonatomic, retain) IBOutletCollection(UIButton) NSArray *buttons;

.m

@synthesize buttons;

- (void)viewDidLoad
{
    [self setValue:[UIFont fontWithName:@"NeverSayNever" size:22] forKeyPath:@"buttons.font"];
    [super viewDidLoad];
}

- (void)viewDidUnload
{
    buttons = nil;
}

- (void)dealloc
{
    [buttons release]; --> Error
    [super dealloc];
}

Why does my program crash when I have [release buttons]; in dealloc? This is not a failure without him ...

0
source share
3 answers

updated (Dec1) and tested.

- (void)dealloc {

    self.buttons = nil;

    [super dealloc];
}

you must not let them go.

http://www.bobmccune.com/2011/01/31/using-ios-4s-iboutletcollection/

+2
source

If you made a connection to your buttons using Interface Builder, this is your view that owns it and releases it.

0
source

All Articles