Created
January 20, 2016 07:59
-
-
Save Bashta/9f5d56ba0af25ba1c5a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func fetchUserFriendsList() { | |
FBSDKGraphRequest(graphPath: "/me/taggable_friends", parameters: ["fields":"id", "limit": 5000]).startWithCompletionHandler({ connection, results, error in | |
guard let resutlsDictionary = results as? NSDictionary, | |
let friends = resutlsDictionary.valueForKey("data") as? [NSDictionary] else { | |
return | |
} | |
var friendsArray:[String] = [] | |
for friend in friends { | |
if let id = friend.valueForKey("id") as? String { | |
friendsArray.append(id) | |
} | |
} | |
DataManager.sharedInstance.saveUsersFriendsToParse(friendsArray) | |
}) | |
} | |
func fetchCurrentUsersLikes(nextPageUrlString: String?, failureHandler: (error: NSError) -> Void) { | |
var parameters = ["fields":"id"] | |
if let nextPageUrlString = nextPageUrlString { | |
parameters["after"] = nextPageUrlString | |
} | |
FBSDKGraphRequest(graphPath: "me/likes", parameters: parameters).startWithCompletionHandler { connection, results, error in | |
guard let userLikes = results as? NSDictionary else { | |
return | |
} | |
self.likeCounter += userLikes.count | |
guard let afterUrlString = userLikes.valueForKeyPath("paging.cursors.after") as? String else { | |
DataManager.sharedInstance.saveUsersLikeCountToParse(self.likeCounter) | |
return | |
} | |
self.fetchCurrentUsersLikes(afterUrlString, failureHandler: { error in }) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment