I wrote the following code to log in to my Facebook account, and then posted a comment on the user's facebook wall. It works great and posts everything mentioned below on the Facebook wall, but that throws the following exception and terminating the application is abnormal. I scratched my head, but could not find anything wrong. Can someone tell me what is wrong in my code? FYI I combined this code with link1 and link2 Thank you!
An exception:
-[NSConcreteMutableData objectForKey:]: unrecognized selector sent to instance 0x34a560 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteMutableData objectForKey:]: unrecognized selector sent to instance 0x34a560'
Enter Facebook code:
- (void)login { NSLog(@"Logging into Facebook..."); UniversalAppAppDelegate *delegate = (UniversalAppAppDelegate *) [[UIApplication sharedApplication] delegate]; NSArray* requiredPermissions = [NSArray arrayWithObjects:@"read_stream", @"publish_stream", @"offline_access",nil]; if (![[delegate facebook] isSessionValid]) { [delegate facebook].sessionDelegate = self; [[delegate facebook] authorize:requiredPermissions]; } }
Placement on the wall:
- (void)postCommentToFacebookWall:(NSString*)comment { UniversalAppAppDelegate *delegate = (UniversalAppAppDelegate *) [[UIApplication sharedApplication] delegate]; NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: kAppId, @"api_key", @"This is test message from my iPhone App",@"message", nil]; [[delegate facebook] requestWithMethodName:@"stream.publish" andParams:params andHttpMethod:@"POST" andDelegate:self]; }
source share