Hii all, m trying to make a 2d byte array . can any body give the code how to declare a NULL 2d byte array in Obj C for iPhone?
Thanks all.
Hii all, m trying to make a 2d byte array . can any body give the code how to declare a NULL 2d byte array in Obj C for iPhone?
Thanks all.
Since objective-c is a strict superset of c, you could just use a pure c definition and it would work fine:
char** myMatrix = malloc(width*height);
You could also use an NSArray of NSArrays, but that's not a 2 dimensional array. It's a jagged array and considerably less easy to use than a plain byte array.
Another alternative is using an NSData/NSMutableData object. That is the Foundation way of working with byte arrays. See NSMutableData class reference for more information.
NSMutableData* data = [NSMutableData dataWithLength:1024]; // One kilobyte
void* dataPointer = [data mutableBytes]; // Get a pointer to the raw bytes