Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm thinking about writing an application that will have a web-version and an iPhone version (and perhaps later also an android version).

Since there is some algorithms that are the same on the iPhone and the web versions, I was wondering if it is possible to write that part in c++, while keeping the rest of the application in objective-c?

share|improve this question

2 Answers 2

up vote 6 down vote accepted

Absolutely. You can write in C and C++, as well as Objective-C. Your algorithms can easily be in straight C++.

(This should be a StackOverflow.com question, btw. It's off-topic here.)

share|improve this answer
1  
imo you're probably also better off writing the algorithms in c++: suppose you want to reuse them later you won't be tied to objective-c –  stijn Feb 21 '11 at 8:17
2  
I was thinking of SO, but according to the P.SE faq, it allows questions on "Architecture", where SO is about "Specific programming problem, software algorithms, coding". I believe that this question falls in the first category. –  Pete Feb 21 '11 at 9:21

Yes, as others have mentioned you can mix C and C++ in with ObjectiveC. It's worth noting, though, that any code that makes of the Aqua GUI or Cocoa has to rely on Objective-C. So, you could re-use existing business logic in C++ and "wrap" it with Objective-C. I know a number of people have done this with existing game frameworks coded in C++.

Scott

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.