'FBSDKGraphRequest Instance method '-startWithCompletionHandler:' not found (return type defaults to 'id')
I'm not ObjectiveC savvy or iOS savvy but I'm trying to muddle through this new issue with this code. I updated the Facebook SDK pod to v12.0.0 and now I'm getting this warning :
Instance method '-startWithCompletionHandler:' not found (return type defaults to 'id') on the last line of the following code block.
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:_graphPath
parameters:arrayParams
HTTPMethod:_httpMethod];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error)
{
Project will build and run, but when this code is called the graph request is made and then it throws an exception :
terminating with uncaught exception of type NSException *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FBSDKGraphRequest startWithCompletionHandler:]: unrecognized selector sent to instance 0x28241b000'
Official Facebook Docs say to implement like this :
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSLog(@"fetched user:%@", result);
}
}];
The xcode warning is still there for startWithCompletionHandler not being found and the exception still gets thrown using this code block.
Any direction would be greatly appreciated as I've Googled myself into a stupor!
Solution 1:[1]
Ok finally hit the right Google combination and found : https://github.com/facebook/facebook-ios-sdk/blob/main/FBSDKTVOSKit/FBSDKTVOSKit/FBSDKDeviceLoginViewController.m
Here it gives an example of the new startWithCompletion instead of startWithCompletionHandler.
FBSDKGraphRequest *graphRequest = [[FBSDKGraphRequest alloc] initWithGraphPath:_graphPath
parameters:arrayParams
HTTPMethod:_httpMethod];
[graphRequest startWithCompletion:^(id<FBSDKGraphRequestConnecting> connection, id result, NSError *error) {
Thanks @Larme for highlighting the right direction!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | clee2005 |
