How to call an Objective-C Method from a C Method?

后端 未结 5 1028
慢半拍i
慢半拍i 2020-11-28 06:44

I have an Obj-C object with a bunch of methods inside of it. Sometimes a method needs to call another method inside the same object. I can\'t seem to figure out how to get

5条回答
  •  臣服心动
    2020-11-28 07:24

    C function is not "inside of the self object". In fact, nothing is.

    Objective-C methods effectively get self as an implicit argument, with magic done under the hood. For plain C functions, they aren't associated with any class or object, and there's no call magic, so no self. If you need it, you need to pass it to your C function explicitly as an argument.

提交回复
热议问题