IBOutlet集合发布问题 [英] IBOutlet collection release problem

查看:51
本文介绍了IBOutlet集合发布问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于IBOutlet集合的数组

I have an array for 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];
}

为什么当我有[释放按钮]时程序崩溃?在dealloc中?没有它,它不会崩溃...

Why does my program crash when I have [buttons release]; in dealloc? Without it, it doesn't crash...

推荐答案

更新(Dec1)代码并经过测试.

updated(Dec1) code and Tested.

- (void)dealloc {

    self.buttons = nil;

    [super dealloc];
}

您不应释放它们.

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

这篇关于IBOutlet集合发布问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆