开发者

Application Crashes on Dealloc

开发者 https://www.devze.com 2023-03-29 20:30 出处:网络
I load my view from xib. And when try to release it crashes with message: Designer Project(72849,0xa08c0540) malloc: * error for object

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:(NSIn开发者_运维问答teger)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.


Try autoreleasing chevrons.

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

Hope this may help.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消