Can we convert an NSArray to a C array?
If not what alternatives, are there? Suppose I need to feed the C array to OpenGL functions where the C array contains vertex pointers read from plist files.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The answer depends on the nature of the C-array.
If you need to populate an array of primitive values and of known length, you could do something like this:
Here’s an example where we want to create a new C-array from an
NSArray, keeping the array items as Obj-C objects:Or, you might want to
nil-terminate the array instead of passing its length around: