Can I inline static class methods in Objective-C?

后端 未结 3 1301
情深已故
情深已故 2021-01-13 05:50

You can declare functions as inlines like this:

#ifdef DEBUG
void DPrintf(NSString *fmt,...);
#else
inline void DPrintf(NSString *fmt,...) {}
#endif
<         


        
3条回答
  •  旧时难觅i
    2021-01-13 06:08

    Be careful. Objective-C methods are not the same as C functions. An Objective-C method is translated by the compiler into the objc_msgSend() function call; you don't have control over whether a method is inline or not because that is irrelevant. You can read more about the Objective-C runtime here (Objective-C Runtime Programming Guide), here (Objective-C Runtime Reference), and here (CocoaSamurai post), and a quick Google search should bring up more info.

提交回复
热议问题