Is it OK to use C++ for business and Objective-C for presentation?
We have a program developed for Windows, the business layer is in pure C++ without any Windows related stuff(e.g CString) and we plan to migrate it to IPhone.
What I'm thinking is that we can use the exisiting code (with little changes if needed) and use Object-C to develop a UI. Is this idea possibl开发者_Go百科e?
Best regards, Zach
Edit
Another question: Are STL and boost well supported?
Oh yes, this is entirely possible. You'd be using Objective-C++, which is merely a different file extension. (You'd save your .cpp
files as .mm
files).
Yes, that sounds like a great candidate for porting. "Objective-C++" allows you to use and call C++ from within Obj-C objects. Assuming your business logic is easily separable, and doesn't have too many win32-isms in it that require explicit porting work, you should be fine doing this.
yes definitely!, you might want to look at objective-c++ at the docs. There are a few gotchas that you should be careful off. Basically you are implementing the model layer in c++ and the view, controller layer in objective-c, this is quite a common design pattern used in many cross-platform projects.
I think that one of the strongest reasons for having the UI developed using Cocoa is down to, "when in Rome, do as the Romans do". A fully native experience can only reasonably be achieved using Cocoa and your users will love you for it. Similarly I'd be using .NET for developing the UI on Windows.
Our applications end up having about 70% of its code base remaining portable across platforms following this approach.
精彩评论