1

我正在使用 Facebook SDK 快速获取用户个人资料数据,但调用 FBRequestConnection.startWithGraphPath:completionHandler: 会迅速崩溃。

我会留下我认为是日志的相关部分

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

我已经填写了错误报告。现在,除了使用 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
    );
4

2 回答 2

2

尝试这个:

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

于 2014-09-11T12:00:59.080 回答
0

最后,我不得不使用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

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

于 2014-07-09T13:38:36.963 回答