应用程序在Dealloc上崩溃

时间:2011-08-19 12:18:05

标签: objective-c uiview crash xib

我从xib加载我的视图。当尝试释放它时会崩溃并显示消息:

  

Designer Project(72849,0xa08c0540)malloc: *对象的错误   0x4b06000:未分配被释放的指针   * 在malloc_error_break中设置断点以调试当前语言:   汽车;目前的目标-c

这是我的实施:

@interface ACLine : UIView {

    NSMutableArray *chevrons;
}

- (void)addChevron:(ACChevron *)aChevron;
- (void)addChevron:(ACChevron *)aChevron atIndex:(NSInteger)anIndex;

- (void)removeAllChevrons;
- (void)removeChevron:(ACChevron *)aChevron;
- (void)removeChevronAtIndex:(NSInteger)anIndex;

- (void)update;

@property (nonatomic, retain) NSMutableArray *chevrons;

@end

@implementation ACLine

@synthesize chevrons;

- (void)awakeFromNib {

    chevrons = [[NSMutableArray alloc] init];
}

- (void)dealloc {
    self.chevrons = nil; 
    [super dealloc]; it crashes here
}

请帮助解决问题。 谢谢。

2 个答案:

答案 0 :(得分:0)

您是否尝试添加“[super awakeFromNib];”在“ - (void)awakeFromNib {”?

之后

答案 1 :(得分:0)

尝试自动释放V形臂。

 chevrons = [[[NSMutableArray alloc] init] autorelease];

希望这可能会有所帮助。

相关问题