Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Objective-C and pass by value

Hello, although The Objective-C Language Reference say that always objects must be references with pointers, I have discovered that Objective-C functions can have parameters that accept objects by value:

Point* Sum(Point p1, Point p2)
{
Point* sol = [Point new];
[sol setX:[(&p1) x]+[(&p2) x]];
[sol setY:[(&p1) y]+[(&p2) y]];
return sol;
}

I could call this function like this:

Point* p3 = Sum( p,p2);

Is this a C backward compatibility issue, or is there any Objective-C undocumented feature.

iBook, Mac OS X (10.4.6)

Posted on May 28, 2006 3:27 AM

Reply
Question marked as Best reply

Posted on May 28, 2006 8:00 AM

Objective-C is a strict superset of C. Objective-C objects are implemented as C structs. C allows passing and assignment of structs.
1 reply

Objective-C and pass by value

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.