Search code examples
ioswarningsincompatibility

Assigning to 'id<NSXMLParserDelegate>' from incompatible type 'FBXMLHandler *'?


I am getting a Assigning to 'id' from incompatible type 'FBXMLHandler *' warning in the bolded line. This warning is in ShareKit and I am looking for a way to fix it.

    FBXMLHandler* handler = [[[FBXMLHandler alloc] init] autorelease];
  NSXMLParser* parser = [[[NSXMLParser alloc] initWithData:data] autorelease];
  ***parser.delegate = handler;***
  [parser parse];

Solution

  • Your handler class doesn't implement the protocol required by the NSXMLParser delegate (which is NSXMLParserDelegate). Read the documentation here for the delegate:

    http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSXMLParserDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/NSXMLParserDelegate

    Once your make your handler class conform to this protocol, the error will go away.