2
votes

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Facebook authorize:delegate:]: unrecognized selector sent to instance 0x684fe80'

- (void)loginToFacebook:(id) loginDelegate
{
    NSLog(@"login facebook method");

    fbServiceRequestingobj = loginDelegate;

    NSArray* permissions = [[NSArray alloc] initWithObjects:@"publish_stream", nil];
    [facebook authorize:permissions delegate:self];

}
2

2 Answers

1
votes

the message is pretty straightforward: the parameter loginDelegate, which you set as the delegate, does not respond to the selector. to verify the parameter when you set it:

- (void)loginToFacebook:(id)loginDelegate
{
  assert([loginDelegate respondsToSelector:@selector(authorize:delegate:)]);

chances are good in this scenario, that the selector in question is a @required method for the protocol you are expected to adopt. if so, then the parameter you pass as loginDelegate would need to implement the method authorize:delegate: declared in the protocol.

when adopting a protocol, the compiler can inform you if you do not implement the required methods.

0
votes
[facebook authorize:permissions delegate:self];

Does this method exist for the "facebook" object? I'd imagine not, as it is crashing saying that this method doesn't exist, hence the "unrecognized selector sent to instance".