Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mlopres

macrumors newbie
Original poster
Jan 12, 2010
4
0
First of all, pardon my complete newbness as I'm completely new to developing on MAC along with Cocoa, and Obj-C

So I'm doing some very basic trial and error testing, as I get accustomed to Objective C.

Right now i have two simple classes. I have my model class which adds two numbers, and is written in C++. I also wrote a Controller class written in Objective C, which will handle functions when a Button is pressed on the GUI and will contain an instance of the model class.

My question is, how can I succesfully compile this project, as the errors I'm getting lead me to believe I'm missing something in order to successfully mix the two languages.

Thanks!

P.S. I've tried renaming the ModelClass.cpp to ModelClass.mm and nothing happened.
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
Rename your controller class to .mm as well. If it contains a C++ object, it needs to be compiled as Objective-C++. if your c++ class contains no objective-C, it can stay .cpp.

-Lee
 

mlopres

macrumors newbie
Original poster
Jan 12, 2010
4
0
lee,

that fixed the issue.


thanks!!


One, other quick question. When I'm working within the Controller class and using the model class instance, which language syntax do I use.
 

Sander

macrumors 6502a
Apr 24, 2008
521
67
If you're using a C++ object from within Objective-C code, you use the C++ syntax. If you're using an Objective-C object from withing C++ code, you use the Objective-C syntax.

It's really mix-and-match, with only a few exceptions (member variables in one language inside objects of another have a few restrictions).
 

Detrius

macrumors 68000
Sep 10, 2008
1,623
19
Apex, NC
First of all, pardon my complete newbness as I'm completely new to developing on MAC along with Cocoa, and Obj-C

When you call a Macintosh a MAC, you sound like you've barely ever even heard of them. It's not an acronym. It's a Mac.

MAC = Medium Access Control, something that's used at the physical ethernet layer. Don't confuse these. It annoys people... about like confusing "there," "their," and "they're." ;)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.