【问题标题】:Application Crashes on DeallocDealloc 上的应用程序崩溃
【发布时间】:2011-08-19 12:18:05
【问题描述】:

我从 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
}

请帮助解决问题。 谢谢。

【问题讨论】:

    标签: objective-c uiview crash xib


    【解决方案1】:

    尝试自动释放 V 形。

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

    希望这会有所帮助。

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 2012-07-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多