应用程序在 Dealloc 上崩溃

发布于 2024-11-30 13:24:52 字数 847 浏览 3 评论 0原文

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

设计器项目(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
}

请帮助解决问题。 谢谢。

I load my view from xib. And when try to release it crashes with message:

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

Here is my implementation:

@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
}

Please help with solving the problem.
Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

人疚 2024-12-07 13:24:52

尝试自动释放 V 形。

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

希望这会有所帮助。

Try autoreleasing chevrons.

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

Hope this may help.

唯憾梦倾城 2024-12-07 13:24:52

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

Did you try adding "[super awakeFromNib];" after "-(void)awakeFromNib {" ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文