Will my iPhone app take a performance hit if I use Objective-C for low level code?

后端 未结 8 1960
生来不讨喜
生来不讨喜 2020-12-04 07:57

When programming a CPU intensive or GPU intensive application on the iPhone or other portable hardware, you have to make wise algorithmic decisions to make your code fast.

8条回答
  •  [愿得一人]
    2020-12-04 08:02

    This study says to really get the performance in a CPU intensive game, you have to use C. The linked article is complete with a XCode project that you can run.

    I believe the bottom line is: Use Objective-C where you must interact with the iPhone's functions (after all, putting trampolines everywhere can't be good for anyone), but when it comes to loops, things like vector object classes, or intensive array access, stick with C++ STL or C arrays to get good performance.

    I mean it would be totally silly to see position = [[Vector3 alloc] init] ;. You're just asking for a performance hit if you use references counts on basic objects like a position vector.

提交回复
热议问题