0
嗨,我試圖找出如何在迅速改寫這個:Objective-C的斯威夫特:Facebook的iOS的API requestUserInfo方法
- (IBAction)requestUserInfo:(id)sender
{
// We will request the user's public picture and the user's birthday
// These are the permissions we need:
NSArray *permissionsNeeded = @[@"public_profile", @"user_birthday", @"email"];
// Request the permissions the user currently has
[FBRequestConnection startWithGraphPath:@"/me/permissions" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error){
// Parse the list of existing permissions and extract them for easier use
NSMutableArray *currentPermissions = [[NSMutableArray alloc] init];
NSLog(@"The fucking class is: %@", [result class]);
NSArray *returnedPermissions = (NSArray *)[result data];
for (NSDictionary *perm in returnedPermissions) {
if ([[perm objectForKey:@"status"] isEqualToString:@"granted"]) {
[currentPermissions addObject:[perm objectForKey:@"permission"]];
}
} // cut cut here
}
編輯:
我遇到了麻煩試圖獲得所需數據從FBGraphObject中提取出來,但在進一步檢查後發現。我已經發布了下面的swift版本,以便人們可以剪切並粘貼它並繼續使用swift。希望它可以節省一些時間。
「的有源訪問令牌必須用於查詢有關當前用戶的信息 – pkc456 2015-07-10 09:57:29