objective-cobjective-c-protocol

assigning protocol parameter to object member


In my header file i am defining a class member:

id<IAdmobTestSuite>* testSuite;

Later i want to assign this variable using this function:

- (void) setTestSuite:(id<IAdmobTestSuite>)_testSuite {
if(testSuite == nil) {
    testSuite = _testSuite;
  }
}

but here xcode show we this error: "Assigning to 'id IAdmobTestSuite *' from incompatible type 'id IAdmobTestSuite '; take the address with &"

Dont really understand this error, How can i properly assign this member?


Solution

  • id is a pointer, to fix the error you should remove the * in your header

    id<IAdmobTestSuite> testSuite;