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 {" ?
精彩评论