objective-c++

Language Mixing: Model and View

Consider developing an application where the model will be written in C++ (with Boost), and the view will be written in Objective-C++ (with Cocoa Touch). Where are some examples showing how to integrate C++ and Objective-C++ for developing iPhone applications? ...

Track all Objective-C's alloc/allocWithZone/dealloc

Sorry for long description, however the questions aren't so easy... My project written without GC. Recently I found a memory leak that I can't find. I did use new Xcode Analyzer without a result. I did read my code line by line and verified all alloc/release/copy/autorelease/mutableCopy/retain and pools... - still nothing. Preamble: St...

How to use c++ template class in objective C

Hi Friends, I want to use a Template class of C++ in my Objective C project. I have read that it is supported. When I try to import the template class that is written in C++ I get lot of errors like Cannot find protocol declaration for 'class' etc.. Can anyone give me a simple example of this. Waiting for reply. ...

Cocoa and Objective-C++

Hey guys! I think I understand how Objective-C++ works in relation to Cocoa, and I am fairly versed in the basics of command-line C++ but sort of afraid to try mixing it with Objective-C. I can create a GUI with Interface Builder in Xcode, and even make classes (.h and .m files) for the interface automatically. The outlets, maybe action...

Differences between objective-c vs objective-c 2.0

question says it all. (I reserved 2 library books which came on the same day. I saw them on the shelf and realized that they were the same except one was ObjC and one was ObjC 2.0. (not full titles...) Bonus, what is Objective C++? objectie ...

The Objective-C++ language: where can I find more information about it?

I've been learning C++ for some months now and find it an excellent language albeit its perks. I was wondering what exactly is the so-called Objective-C++ and if it's worth learning it as a main development language to target Apple environments (ie. Mac OS X, iPhone OS). Searching around the web I only found a couple of good articles: m...

Convert const char* string to NSString with length AND encoding

I wonder which method would be better to convert const char* string to NSString. I found there are some facts. [NSString stringWithCString:length:] is kind of deprecated. [NSString stringWithCString:encoding] may be used for my purpose But I want to convert with length AND encoding(because I want to make that fine if I have some Non-...

xcode "compile source as" override for specific file

Hello, I have a project that has to be set to "Objective-C++" for the "compile source as" value (no, "according to file type" will not work in my main project). I am having a problem with a file I got from a framework (specifically OpenFeint) that has compile errors when compiled as "Objective-C++". error: pointer of type 'void *' used...

Does it prohibited calling classic C function from Objective-C++ class method body?

I have experienced some strange behavior of Objective-C++. I have an Objective-C++ class, and it calls a classic C function in a method body. But linker cannot find the C function. I described the problem here: http://stackoverflow.com/questions/2213589/xcode-print-symbol-not-found-for-my-c-function-which-used-in-objective-c-method-b/22...

Calling a C++ object's method from an Objective-C child object

I have some Objective-C++ code that I'm trying to get events out of an Objective-C object to call a method within a C++ object. I'm very new to Objective-C, so I may be doing this all wrong. Example: @interface KnobClass { } -(void)Event; @end class DoorClass { public: KnobClass * knob; void start() { knob = [[KnobClass a...

Can I separate C++ main function and classes from Objective-C and/or C routines at compile and link?

I have a small C++ application which I imported Objective-C classes. It works as Objective-C++ files, .mm, but any C++ file that includes a header which may end up including some Objective-C header must be renamed to a .mm extension for the proper GCC drivers. Is there a way to write either a purely C++ wrapper for Objective-C classes ...

Objective-C, .m / .mm performance difference?

I tend to use the .mm extension by default when creating new classes so that I can use ObjC++ later on if I require it. Is there any disadvantage to doing this? When would you prefer .m? Does .m compile to a faster executable (since C is generally faster than C++)? ...

Using C++ classes within Objective-C++

I am using a small C++ library in a Cocoa application (atm just a very simple example to learn how I should do it). So I have a small C++ class in a namespace looking like follows: namespace testlib { class Test { public: Test(unsigned a); Test operator+(const Test& other) const; Test operator+(unsigned other) const; Te...

C++ and Objective C in Xcode project

I have recently updated Xcode to version Version 3.2.2 (Pre-release). It is working fine with old Objective-C projects but I experience some problems with projects which have mix of Objective-C/Objective-C++ code. During the compilation I am getting the following error: /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.s...

Strings in Objective-C++

I just switched my code from Objective-C to Objective-C++. Everything goes swimmingly except for two lines. NSString * text1=[[NSString stringWithFormat:@"%.2f",ymax] UTF8String]; This line complains that error: cannot convert 'const char*' to 'NSString*' in initialization The second error related to the first is from the line: CG...

What do I need to know to manage memory in Objective C++?

I'm working with a C++ audio library in an iPhone app. Is there any Objective C / Cocoa memory management infrastructure I can use for my C++ objects, or do I need to just read up and learn C++ memory management? ...

Trouble using opaque pointers in Objective C++

The answer to this quesion explains that opaque pointers are a good way to include C++ member variables in an Objective C++ header. I'm getting compile errors when trying to follow the example. Here's the relevant code from my header, with the corresponding compiler errors shown as comments: struct ADSR_opaque; // error: forward declara...

0 not a valid FILE* when provided as a template argument

The following code #include <stdio.h> template <typename T, T v> class Tem { T t; Tem() { t = v; } }; typedef Tem<FILE*,NULL> TemFile; when compiled in a .mm file (Objective C++) by Xcode on MacOS X, throws the following error: error: could not convert template argument '0' to 'FILE*'. What's going on, pleas...

Objective-C with some Objective-C++, calling a normal c++ method "referenced from" problem

Hi, I made an Objective-C project for the iPhone. I had only one cpp class, the soundEngine taken from some Apple demo. Now I'm trying to merge OpenFeint which is coded in Objective-C++. I dropped in the code, by simply dragging the files and just tick "Call C++ default ctors/dtors in Objective-C" in Project Settings. I am not even refer...

No Debug information of an iPhone app

Hi all, I wrote an iPhone app which uses a third party library. I crosscompiled this library successfully and everything works smoothly. But when I want to debug the application, it would make sense to also be able to debug the library. So I compiled also the external library with debuging information (usign the gcc option -ggdb). But w...