gpt4 book ai didi

objective-c - 应用程序在Dealloc上崩溃

转载 作者:行者123 更新时间:2023-12-03 17:42:03 25 4
gpt4 key购买 nike

我从xib加载 View 。当尝试释放时,它崩溃并显示以下消息:

Designer Project(72849,0xa08c0540) malloc: * error for object 0x4b06000: pointer being freed was not allocated * set a breakpoint in malloc_error_break to debug Current language: auto; currently objective-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
}

请帮助解决问题。
谢谢。

最佳答案

尝试自动释放人字形。

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

希望这会有所帮助。

关于objective-c - 应用程序在Dealloc上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7121431/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com