NSArray and C array
NSArray and C array
- Subject: NSArray and C array
- From: Drew McCormack <email@hidden>
- Date: Sat, 27 Oct 2001 21:39:47 -0700
I think I can remember seeing in the documentation an example which cast
an NSArray to a C array, but I can't seem to find it.
I think it was something along these lines:
NSArray *array = [NSArray arrayWithObject:obj];
id *carray;
carray = (id *)array;
[carray[0] doSomething];
Is this possible, or am I dreaming? If it is possible, why? Where does
it say that the data in an NSArray is layed out in such a way that this
cast will work?
(I guess a better way to do this would be to use the initWithObjects:
and getObjects: methods, but I just wanted to know if this cast was
possible, and why.)
Drew McCormack