I've been using
NSMutableData* mutableData = [NSMutableData dataWithLength: someLength];
void* bitmapData = [mutableData mutableBytes];
CGContextRef context = CGBitmapContextCreate(bitmapData,...);
// ...use context
CGContextRelease(context);
I have an autorelease pool in place, but when looking at this in Instruments, mutableData
doesn't seem to be deallocated.
I thought of using alloc
/init
like below, but I'm not sure if sending release
would purge bitmapData
as well.
NSMutableData* mutableData = [[NSMutableData alloc] initWithLength: someLength];
void* bitmapData = [mutableData mutableBytes];
[mutableData release];
//...
What's the proper way of using NSMutableData
here?
I thought using NSMutableData
instead of malloc()
and free()
would be convenient because it'll be autoreleased. but now I'm not sure if that's true.