应用程序在 Dealloc 上崩溃
我从 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试自动释放 V 形。
希望这会有所帮助。
Try autoreleasing chevrons.
Hope this may help.
您是否尝试添加“[super awakeFromNib];”在“-(void)awakeFromNib {”之后?
Did you try adding "[super awakeFromNib];" after "-(void)awakeFromNib {" ?