Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
What is the most efficient way to copy an array of 1000 ints from one array to another in objective C?
This will be running on an iphone within some drawing code so its important to be as efficient as possible.
Thanks.
if the concern is efficiency, I'm assuming this is a C array of ints. If so, you can use memcpy().
For example:
int copyOfArr[4], arr[4] = {0,1,2,3}; memcpy(copyOfArr, arr, sizeof(arr));
Hope that helps.
Add a comment
If you are talking about a normal C array, then memcpy is the most efficient way. If you are talking about NSArray, then send a "copy" message.
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.