Darren Findlay
Darren Findlay

Reputation: 2563

C function in an objective-C class

If I create a C style function in an objective C class, will the function be a class level method? Or an instance method?

Thanks in advance

Upvotes: 0

Views: 264

Answers (2)

idz
idz

Reputation: 12988

If you create a C function in Objective-C, it will not have any relationship to a particular class. That is, it will be in the global namespace. An example of this from the SDK is NSLog(...).

Upvotes: 3

mipadi
mipadi

Reputation: 410582

You can't attach C functions to an Objective-C class. If you want a "function" attached to a class, you have to declare it as a class method. Or you can declare the function outside of the class.

Upvotes: 0

Related Questions