FBRequestConnection.startWithGraphPath很快崩溃



我使用Facebook SDK在swift中获取用户配置文件数据,但调用FBRequestConnection。startWithGraphPath:completionHandler:正在崩溃swift.

我将保留日志中我认为相关的部分

1.  While type-checking 'profile' at /Users/fratelli/Documents/Projects/Wink/Wink/OAuthFacebookSession.swift:118:14
2.  While type-checking expression at [/Users/fratelli/Documents/Projects/Wink/Wink/OAuthFacebookSession.swift:139:9 - line:142:9] RangeText="FBRequestConnection.startWithGraphPath(
            self.readPermissions(),
            completionHandler: completionHandler
        )"
<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: swift frontend command failed due to signal (use -v to see invocation)
Command /Applications/Xcode6-Beta3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 254

我已经填好bug报告了。现在,除了使用Objective-c,我看不出还有什么别的办法。我想知道的是,如果有任何其他FB SDK方法,我可以尝试达到相同的效果。

代码如下:

    var completionHandler = {
        connection, result, error in
    } as FBSessionStateHandler;
    // Request the profile info
    FBRequestConnection.startWithGraphPath(
        "me?fields=birthday,gender,first_name,last_name,name_format,picture",
        completionHandler: completionHandler
    );

试试这个:

var completionHandler = {
    connection, result, error in
} as FBRequestHandler;
// Request the profile info
FBRequestConnection.startWithGraphPath(
    "me?fields=birthday,gender,first_name,last_name,name_format,picture",
    completionHandler: completionHandler
);

FBRequestConnection。startWithGraphPath期望FBRequestHandler,而不是FBSessionStateHandler

最后,我不得不使用Objective-c。所以我创建了一个oauthfacebookwrapper。h文件

#import <Foundation/Foundation.h>
#import <FacebookSDK/FacebookSDK.h>
@interface OAuthFacebookWrapper : NSObject
+ (void) startWithGraphPath:(NSString *)graphPath completionHandler:(FBRequestHandler)handler;
@end

然后OAuthFacebookWrapper.m

#import "OAuthFacebookWrapper.h"
@implementation OAuthFacebookWrapper
+ (void) startWithGraphPath:(NSString *)graphPath completionHandler:(FBRequestHandler)handler
{
    [FBRequestConnection startWithGraphPath: graphPath completionHandler: handler];
}
@end

使用与之前相同的参数调用该方法。

相关内容

  • 没有找到相关文章

最新更新