• 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: NSOutlineViews and C++ objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSOutlineViews and C++ objects


  • Subject: Re: NSOutlineViews and C++ objects
  • From: kelvSYC <email@hidden>
  • Date: Fri, 13 May 2005 22:02:22 -0600

I want to write a class that implement NSOutlineViewDataSource, but the problem is that all my data for the outline view is stored as C++ classes. What is the best way to do this?


You can mix Obj-C and C++ in the same file, just give the file a .mm extension and Xcode will compile it as an Objective-C++ file. Then just implement the NSOutlineViewDataSource as wrappers around the C++ classes. i.e. you have a Cocoa object that is the datasource of the OutlineView and which has whatever C++ objects are needed as instance variables.



The problem is that my information is stored in a structure like so:

class A;
class B;

class A {
    std::vector<B> bList;
};

std::vector<A> aList;

The idea is that the children of nil are the NSValues representing elements in aList, and their children are NSValues representing the elements in their respective bList. However, it seems that if I do so, I lose key information such as whether a given NSValue represents an A or a B (plus, I'm not overly comfortable working with void*). What's the most elegant solution to do so? Typefields, NSDictionary<NSString, NSValue>, C++ RTTI, or something completely different?
_______________________________________________
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
References: 
 >NSOutlineViews and C++ objects (From: kelvSYC <email@hidden>)
 >Re: NSOutlineViews and C++ objects (From: Glen Simmons <email@hidden>)

  • Prev by Date: Re: FSCopyObjectAsync: useless and crippled
  • Next by Date: How to get observe KVO changes to *every* key for an object?
  • Previous by thread: Re: NSOutlineViews and C++ objects
  • Next by thread: Re: NSOutlineViews and C++ objects
  • Index(es):
    • Date
    • Thread