I dont think I’ve understood C well enough.
In my codes, added a call back method.
And inside the method, I want to be able call a method that beings to the instance. I tried [self methodName] but I’m told ‘self is an undeclared identifier`.
Added code snippets:
@implementation TheClass
static void audioRouteChangeListenerCallback (
void *inUserData,
AudioSessionPropertyID inPropertyID,
UInt32 inPropertyValueSize,
const void *inPropertyValue)
{
.
.
//trying to call a instance method of TheClass here.
}
You cannot use
selfin a plain C function, it doesn’t belong to any Objective-C instance (that’s the difference between a function and a method).For callbacks that are supposed to interact with Objective-C, you would usually pass a pointer to your object when you set up the callback. In this case,
inUserDatais probably something that you can set yourself when registering the callback.