• 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
Obj-C++: instantiating C++ type ivar within an obj-c class
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Obj-C++: instantiating C++ type ivar within an obj-c class


  • Subject: Obj-C++: instantiating C++ type ivar within an obj-c class
  • From: Ben Dubin-Thaler <email@hidden>
  • Date: Sun, 28 Aug 2005 05:51:08 -0400

Hello, I'm a biology grad student studying cell motility. I'm developing a technique to figure out how cancer cells crawl around and metastasize.

I am programming a Cocoa app for my analysis using the MVC ethos and I am trying to integrate previously written C++ classes into my code. I have successfully instantiated and used my C++ classes within methods of an Obj-C class.

But I want to go further and actually use my C++ classes - in particular a class called Array2D<type> (a 2d array template) - to store some giant arrays of data as a private instance variable (ivar) in my Obj-C class compiled with Obj-C++. The problem is that when I pass the header of the model class to the controller class, the controller, which is compiled as Obj-C, of course freaks because it doesn't know about these weird C++ classes.

So, is there some way to instantiate the C++ ivars privately so that I can use them within an Obj-C class yet still be able to let the controller Obj-C class know about the non-C++ ivars and methods that it needs to call?

In other words, is there a way to hide part of an Obj-C class' interface from other objects?

All the examples I can find so far don't have to worry about the interface being seen by pure Obj-C objects, they discuss only stand alone Obj-C classes with C++ in them. I'd rather not change everything to Obj-C++ if I don't need to - there's got to be an elegant solution to this.


My headers look something like this:

// SLContour.h
#import <Cocoa/Cocoa.h>
#import <Array2D.h> // <<<< this is where the CPP class is defined, obviously this needs to // be hidden from Obj-C but needs to be visible to ivars in SLContour class that use it as their // type


@interface SLContour : NSObject
{
    NSMutableDictionary* parameters;

@private
    Array2D<double> vnArc; // <<<< these are the CPP class type ivars
    Array2D<int> contourXY;
    Array2D<double> area;
}
- (id) init;
- (NSDictionary*) parameters;
- (void) addParameters: (NSDictionary*)newContourParameters;
- (void) loadJakeContourFromMatfile: (NSString*) matFileName;
@end


I look forward to solving this problem! Thanks, Ben

_______________________________________________
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


  • Follow-Ups:
    • Re: Obj-C++: instantiating C++ type ivar within an obj-c class
      • From: Chris Hanson <email@hidden>
  • Prev by Date: Re: WeakHashMap
  • Next by Date: Re:Obj-C++: instantiating C++ type ivar within an obj-c class
  • Previous by thread: Re: NSSearchField retaining NSDocument?
  • Next by thread: Re: Obj-C++: instantiating C++ type ivar within an obj-c class
  • Index(es):
    • Date
    • Thread