Re: Using C++ classes from Objective C

2008-03-20 Thread Scott Thompson
On Mar 20, 2008, at 2:34 PM, Jeremy wrote: Thanks everyone! Using a void* for the member variable of my wrapper class did the trick and I now have my Objective C code calling my C++ code! What is the best way to pass strings from my Objective C code to my C ++ code though? I started lookin

Re: Using C++ classes from Objective C

2008-03-20 Thread Rob Napier
Yep, stringWithUTF8String/UTF8String works well for std:string. I recommend creating NSStringForStdString() and StdStringForNSString() utility functions, and possibly an NSString category to add -stdStringValue. -Rob On Thu, Mar 20, 2008 at 4:05 PM, Jeff LaMarche <[EMAIL PROTECTED]> wrote: > Wha

Re: Using C++ classes from Objective C

2008-03-20 Thread Jeff LaMarche
What about the UTF8String method? It replaces the old lossyCString method and should give you a pointer to a c string Sent from my iPhone On Mar 20, 2008, at 3:34 PM, Jeremy <[EMAIL PROTECTED]> wrote: Thanks everyone! Using a void* for the member variable of my wrapper class did the trick

Re: Using C++ classes from Objective C

2008-03-20 Thread Jeremy
Thanks everyone! Using a void* for the member variable of my wrapper class did the trick and I now have my Objective C code calling my C++ code! What is the best way to pass strings from my Objective C code to my C+ + code though? I started looking at the unichar definition and the methods on

Re: Using C++ classes from Objective C

2008-03-20 Thread Clark Cox
On Thu, Mar 20, 2008 at 11:33 AM, Christopher Nebel <[EMAIL PROTECTED]> wrote: > On Mar 20, 2008, at 10:32 AM, Rob Napier wrote: > > > Say you have a C++ object called MyObject in the namespace myapp > > that you want to access through your ObjC. What I tend to do is > > create an ObjC++ object

Re: Using C++ classes from Objective C

2008-03-20 Thread Christopher Nebel
On Mar 20, 2008, at 10:32 AM, Rob Napier wrote: Say you have a C++ object called MyObject in the namespace myapp that you want to access through your ObjC. What I tend to do is create an ObjC++ object called MyObjectWrapper that owns a myapp::MyObject and presents a pure ObjC interface to i

Re: Using C++ classes from Objective C

2008-03-20 Thread Rob Napier
Say you have a C++ object called MyObject in the namespace myapp that you want to access through your ObjC. What I tend to do is create an ObjC++ object called MyObjectWrapper that owns a myapp::MyObject and presents a pure ObjC interface to its methods. Users of MyObjectWrapper don't have to inclu

Re: Using C++ classes from Objective C

2008-03-20 Thread Chris Meyer
An easy way of reference counting using Obj-C++ is to use the boost libraries with boost::intrusive_ptr and these definitions: // file.h namespace boost { void intrusive_ptr_add_ref( id object ); void intrusive_ptr_release( id object ); } // file.m namespace boost { void intru

Re: Using C++ classes from Objective C

2008-03-20 Thread John Stiles
Wow. That is a really awesome trick there. Props to you!! I wish Boost was easier to split apart so I didn't need to drag around 40MB of headers for just one featureā€¦ Chris Meyer wrote: Don't listen to these C++ naysayers... we use it all the time very successfully. An easy way of reference

Re: Using C++ classes from Objective C

2008-03-20 Thread Jeremy
Thanks for the input guys, I really appreciate the help. I do have a lot of C++ code that I would like to use and put behind a Cocoa front end, so I think that using Objective C++ classes as wrapper classes around my C++ classes is the route I would like to take. Anyone have an example of s

Re: Using C++ classes from Objective C

2008-03-20 Thread John Stiles
Without starting a religious war, I have to disagree with this. ObjC++ is probably a bad idea if you are a novice programmer in general, but I think it also has some really good things going for it, and having written huge amounts of ObjC++ code, I think it's perfectly straightforward to use.

Re: Using C++ classes from Objective C

2008-03-20 Thread Rob Napier
On Wed, Mar 19, 2008 at 4:12 PM, Jeremy <[EMAIL PROTECTED]> wrote: > Hi. > > I am just starting to learn Cocoa and would like to use standard C++ > classes from my Objective C/C++ classes. You really don't. You think you do (probably because you know C++), but then you enter the crazy messed up

Re: Using C++ classes from Objective C

2008-03-19 Thread Jens Alfke
On 19 Mar '08, at 1:12 PM, Jeremy wrote: I then changed my .m file to a .mm file and all of the errors went away except for one: "cannot find interface declaration for 'MyClass'" The code in my .mm file is as such: m_pMemberVariable = new MyClass(); const unsigned int nRes = m_pMemberVariab

Re: Using C++ classes from Objective C

2008-03-19 Thread Jeremy
Yes, I am. I have tried using both #include and #import, but neither seems to work. On Mar 19, 2008, at 4:22 PM, John Stiles wrote: Are you #including the header which declares MyClass? Jeremy wrote: Hi. I am just starting to learn Cocoa and would like to use standard C+ + classes from

Re: Using C++ classes from Objective C

2008-03-19 Thread John Stiles
Are you #including the header which declares MyClass? Jeremy wrote: Hi. I am just starting to learn Cocoa and would like to use standard C++ classes from my Objective C/C++ classes. Is there any known documentation on how to do this, or does anyone have any pointers? I tried creating a new

Using C++ classes from Objective C

2008-03-19 Thread Jeremy
Hi. I am just starting to learn Cocoa and would like to use standard C++ classes from my Objective C/C++ classes. Is there any known documentation on how to do this, or does anyone have any pointers? I tried creating a new object of my C++ class and calling a method on it in a .m file and