Objective-C++ 2.0 - C++ valued properties
Objective-C++ 2.0 - C++ valued properties
- Subject: Objective-C++ 2.0 - C++ valued properties
- From: Scott Thompson <email@hidden>
- Date: Sat, 15 Mar 2008 22:29:50 -0500
I'm running into an odd error when trying to mix C++ and Objective-C
2.0 features. I wasn't sure if something along these lines is even
supposed to work so I thought I would ask.
What I tried to do was declare a property whose type was a C++
object. Something like (typed into mail so there may be errors):
class Vector3D
{
float x, y, z;
// Vector3D declarations here
};
@interface Object3D
{
Vector3D position;
}
@property (assign) Vector3D position;
@end
What I've discovered is that when I set the value of the property:
myObject.position = Vector3D(1.0, 2.0, 3.0)
Or something like that, that the value of the position property does
not change.
I'm afraid my Intel assembly language is not that great (but getting
better). If I had to interpret what I see in assembly, it looks as
though the "myObject.position" is assigned to a temp and that the
value of the temp is actually taking the value of the Vector3D.
What I do know is that this language feature works for some C
structures, like NSRect, and that there is an object message send with
struct-type call. That method, which I would expect to be invoked in
this case, is apparently not called.
On the whole I expect I've just run into a corner of the Objective-C++
universe that has not been adequately explored. If that is the case,
I'm happy to continue with my life, however, if this is supposed to
work, I'd appreciate knowing that in the hopes that I can figure out
what might be wrong with my code.
Scott
P.S. It would get even weirder if there was an operator= for the
Vector3D class. This code would have to do something like call the
operator, then go back and do the property key-value coding. What
would "setPosition:" do in that case.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden