• 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 wrappers for C++ classes for use in Cocoa Bindings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Objective-C wrappers for C++ classes for use in Cocoa Bindings


  • Subject: Objective-C wrappers for C++ classes for use in Cocoa Bindings
  • From: kelvSYC <email@hidden>
  • Date: Sat, 03 Sep 2005 21:43:46 -0600

What would be a good design strategy for creating a Cocoa interface where the data model is in pure C++?

Suppose I have a C++ class Bar and an obj-C BarWrapper, which contains a Bar* member (Bar is not POD - see below). In class Bar I have a method that returns a std::vector<Bar*> called foo(), and in BarWrapper I have indexed accessors for foo. I also have a std::vector<Bar>, which acts as the master list of Bars, which of course I try to hook up to an NSArrayController.

I have a few issues on the design of BarWrapper that I need expert advice with the following:
* As the NSArrayController manages BarWrappers, how do I make it so that when I effectively add a new BarWrapper, I also need a new Bar without having BarWrapper's initializer use new (and thus use delete in BarWrapper's deallocator)? Is it even possible?
* If I use foo on Bar, should I return new BarWrappers or existing BarWrappers? If the latter, would searching through the NSArrayController's array be too inefficient?
* Another design consideration: when I remove a Bar, I need it so that all BarWrappers that refer to that Bar is removed. This may also affect other Bars and their BarWrappers (as I have to remove the Bar being deleted from the other Bars' foo arrays).


Any help on this would be nice.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: NSTableView
  • Next by Date: Re: 3rd Party Components
  • Previous by thread: Re: 3rd Party Components
  • Next by thread: NSTextView wrapping too soon
  • Index(es):
    • Date
    • Thread