• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Objective-C++ 2.0 - C++ valued properties
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Objective-C++ 2.0 - C++ valued properties
      • From: Jens Ayton <email@hidden>
  • Prev by Date: Re: Three button segmented page control preference in Xcode 3.0
  • Next by Date: Getting line numbers in crash logs with dwarf
  • Previous by thread: Re: Insert Code Into Every Function
  • Next by thread: Re: Objective-C++ 2.0 - C++ valued properties
  • Index(es):
    • Date
    • Thread