Thursday, 29 September 2011

using c with objective c Top Tip


NSMutableData* data = [NSMutableData dataWithLength:sizeof(int) * 100];
int* array = [data mutableBytes];
// memory is already zeroed
// use the array
// decide later that we need more space:
[data setLength:sizeof(int) * 200];
array = [data mutableBytes]; // re-fetch pointer in case memory needed to be copied
// no need to free
// (it's done when the autoreleased object is deallocated)
Just read this on stackoverflow. Think its a good tip

link to thread