[英]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.我不是 ObjectiveC 精通或 iOS 精通,但我试图用这段代码来解决这个新问题。 I updated the Facebook SDK pod to v12.0.0 and now I'm getting this warning:我将 Facebook SDK pod 更新为 v12.0.0,现在我收到以下警告:
Instance method '-startWithCompletionHandler:' not found (return type defaults to 'id') on the last line of the following code block.在以下代码块的最后一行找不到实例方法“-startWithCompletionHandler:”(返回类型默认为“id”)。
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'以 NSException 类型的未捕获异常终止 *** 由于未捕获异常“NSInvalidArgumentException”而终止应用程序,原因:“-[FBSDKGraphRequest startWithCompletionHandler:]:无法识别的选择器发送到实例 0x28241b000”
Official Facebook Docs say to implement like this:官方 Facebook 文档说要这样实现:
[[[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. xcode 警告仍然存在,因为找不到 startWithCompletionHandler 并且使用此代码块仍然会引发异常。
Any direction would be greatly appreciated as I've Googled myself into a stupor!任何方向都将不胜感激,因为我已经用谷歌搜索自己进入昏迷状态!
Ok finally hit the right Google combination and found: https://github.com/facebook/facebook-ios-sdk/blob/main/FBSDKTVOSKit/FBSDKTVOSKit/FBSDKDeviceLoginViewController.m Ok终于打对了Google组合,发现: 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.这里给出了一个新的 startWithCompletion 而不是 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!感谢@Larme 强调正确的方向!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.