Accessing Instance Variable in C Style Method

后端 未结 3 1905
北恋
北恋 2021-01-19 13:07

Can someone confirm that you cannot access instance variables defined in an Objective C @implementation block from within C style functions of the same class? The compiler

3条回答
  •  终归单人心
    2021-01-19 13:55

    That's correct. You seem to be mixing up methods and functions though. Methods exist only in Objective-C. What you're referring to as a 'C style method' is really just a C function.

    C is not an object-oriented programming language. Since there's no such thing as an object in C, there's also no such thing as an instance variable in C, so the fontRef instance variable would not be visible in the function you posted, nor for that matter in any other C function in your program.

提交回复
热议问题