Я храню CGMutablePathRefs внутри NSMutableArray через NSValue.
Вроде так:
CGMutablePathRef path = CreateMutablePath();
[self.myArray addObject:[NSValue valueWithPointer:path]];
В моем dealloc я пробовал это:
- (void)dealloc
{
[super dealloc];
for (int i = 0; i < self.myArray.count;) {
NSValue *currentPath = [self.myArray objectAtIndex:i];
CGMutablePathRef path = (CGMutablePathRef)[currentPath pointerValue];
CGPathRelease(path);
}
self.myArray = nil;
}
Однако, когда я запускаю это, я получаю следующее исключение:
malloc: *** error for object 0x16b250: pointer being freed was not allocated
Может кто-нибудь объяснить мне, почему это так и как мне правильно выпустить CGMutablePathRefs?
Любая помощь приветствуется.