• 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
Re: Get|SetControlProperty() equivalent
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get|SetControlProperty() equivalent


  • Subject: Re: Get|SetControlProperty() equivalent
  • From: Michael Vannorsdel <email@hidden>
  • Date: Thu, 11 Jun 2009 07:43:14 -0600

Subclass NSView and use poseAsClass to replace the default implementation. You'll need to do the posing before running NSApplicationMain. You'll have to use a different approach if you're building for 64-bit.


On Jun 11, 2009, at 7:25 AM, Jo Meder wrote:

Hi Graham,

On 11/06/2009, at 11:50 PM, Graham Cox wrote:

The carbon mechanism exists because in classical procedural code, you can't subclass an "object" because there is no formal "object" to subclass. Therefore storage mechanisms have to be provided to hang extra stuff on.

It's still just a convenience rather than a necessity, there are other ways of doing it. It's a useful convenience though, in this case at least.


In Cocoa, we have proper objects, so you can simply (ingeniously!) subclass the NSControl or NSView as you wish and add any extra data members you want for any purpose you wish. For example you could subclass NSView and add a reference to your C++ object directly as a data member along with suitable accessors for it. If the view needs to be aware of the C++ code itself you can compile it as Objective-C++ using a .mm extension on the source file.

It's not really so simple, because I'd have to subclass all the views/controls I use, which is many of the UI elements available, and that means I have many disparate classes implementing the same functionality. Of course I then need to repeat that for any new controls I support. Less work and maintenance to maintain a map from NSViews to my C++ framework objects. I should have mentioned I had considered and rejected subclassing I guess.


As an aside, I'm using Objective-C++ extensively in my framework. It's quite the godsend really and has made things a lot quicker and easier.

Thanks anyway. I was a long time MacZoop user BTW. Well, some of MacZoop, I used all my own control classes. I use a messaging and commander system inspired by my experience with MacZoop in my own framework.

Regards,

Jo Meder

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Get|SetControlProperty() equivalent
      • From: Graham Cox <email@hidden>
References: 
 >Get|SetControlProperty() equivalent (From: Jo Meder <email@hidden>)
 >Re: Get|SetControlProperty() equivalent (From: Graham Cox <email@hidden>)
 >Re: Get|SetControlProperty() equivalent (From: Jo Meder <email@hidden>)

  • Prev by Date: program crashes because of a variable declaration
  • Next by Date: Re: Outlets not allocated
  • Previous by thread: Re: Get|SetControlProperty() equivalent
  • Next by thread: Re: Get|SetControlProperty() equivalent
  • Index(es):
    • Date
    • Thread