Utilizing C++ in iOS and Mac OS X applications

前端 未结 5 1869
清歌不尽
清歌不尽 2020-11-30 22:09

I\'m somewhat moderate in my C++ knowledge but know next to nothing regarding Objective-C. I am planning (and even starting to) learn Objective-C so I can attempt to write a

相关标签:
5条回答
  • 2020-11-30 22:26

    Changes required in build settings to use C++ files in iOS project under "Apple LLVM compiler 4.2 - Language" Option

    C++ Language Dialect: Compiler Default C++ Standard Library: Compiler Default

    0 讨论(0)
  • 2020-11-30 22:28

    You could use Cocos2d-x engine and write pure C++ for your iOS app, including UI (cocos has basic ui classes like buttons, scroll views, table views, etc - but you need to develop your own Controllers, and Models using various C++ libraries like Hiberlite, or raw SQLite etc)

    Cocos has its own interface with iOS/MacOS (a few basic .mm objective-c classes to setup Application run cycle - like app delegate, or runloop and drawing cycle)

    So you just write your user code with C++

    0 讨论(0)
  • 2020-11-30 22:32

    Is it possible to write an iOS and / or a Mac OS X application entirely with C++ including the UI components? If it isn't possible to do it entirely in C++ then to what degree is it possible to use mostly C++?

    I think it is possible to use pure c++ if you want to depend on some 3rd part lib, then yes.

    Without that 3rd part lib you have to write all the UI using objective-c the rest you can use c++ as much as you like.

    0 讨论(0)
  • 2020-11-30 22:33

    Short answer, yes.

    For pure C++, you should take a look at the QT framework.
    Otherwise, you'll have hard time for the UI part.

    But also remember that Objective-C can be mixed with C++.
    That's called Objective-C++ (.mm files).

    You can then write code that mix C++ and Objective-C code. With this, you can have the UI parts in Objective-C (may be better, as it will use the native frameworks for the UI components), and the other things in C++.

    If you've decided to learn Objective-C, but still want to code in C++ for some parts, I would recommend this approach, instead of pure C++.

    On iOS, this is also the only way. While you can code in C++, you have to use Objective-C for the UI part.

    EDIT

    Here are a few links to get started with Objective-C++:

    • Strategies for Using C++ in Objective-C Projects
    • From C++ to Objective-C
    • CocoaDev
    0 讨论(0)
  • 2020-11-30 22:34

    Look this question

    I don't know about Mac OS, but in IOS applications you can use C++ in logic but you have to write user interface on Objective-C.

    0 讨论(0)
提交回复
热议问题