- For individual users
- Instant access to solutions
- Ask your tech questions
- Start your 30-day Free Trial
Main Topics
Browse All TopicsFor some reason I'm having tremendous trouble doing what would seem to be ( in any other language besides objective-c ) to be no-brainer.
All I want to do is pass an array of float values, or any primitive data type, back and forth between functions. That array does not always have a constant size, if it matters.
See code snipped below... I know it definitely wont compile, but I'm just trying to show my purpose.
Why must this be so difficult!??!
How hard can this be??!? I'm just not finding any good examples is all, so I figured I would come ask the experts!... Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: fridomPosted on 2008-07-04 at 22:02:39ID: 21935898
You're not fully correct this is not a no-brainer in many languages. But there are ways just take this
int *field_of_ints = {1,2,3,4,5,6};
that's fine but there is not assignment for array in C, you either have to do:
int *another_field = field_of_ints
But that won't copy the field entries, it's just another reference to the same location.
Of you have to write an "assignment" yoursel.
int * copy_of_field (int * field, int size) {
int * result = malloc(sizeof(*field) * size);
for (i = 0; i < size; i++) {
result[i] = field[i];
}
return result;
}
Not not all is lost. In Objectice C you could write:
Howerver if you want some more convenient Array functions you must use objects so the
code would look like this:
The "point" is that Objective-C really is an OO extension, it's till C below, and so you just can use all what C offers while using primitive types. If you want to gain from Objects, you explicitly have to ask for "Objects"
Regards
Friedrich
}
Select allOpen in new window