When passing a delegate to MyClass like this,
- (MyClass *)initWithDelegate:(id <MyDelegate>)delegate {..}
is it somehow possible to tell what kind of class my delegate is? Being defined as id, delegate doesn’t seem to respond to any method calls like class, description, respondsToSelector etc.
I’d like to be able to track who is calling MyClass!
Thanks in advance!
/Christian
You can call
[delegate class];to get the class of thedelegate.If
delegatedoesn’t respond to that, that means it isnil.Edit
Now that you mention that you get compiler errors, then your delegate doesn’t conform to the protocol
NSObject. So the compiler doesn’t recognize it as anNSObject. You should modify the declaration of your protocolMyDelegateto the following: