• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSArray and C array
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSArray and C array
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Widget Repository?
  • Next by Date: Re: capturing screenshots from dvd?
  • Previous by thread: Re: Widget Repository?
  • Next by thread: Re: NSArray and C array
  • Index(es):
    • Date
    • Thread