Created
January 5, 2016 04:43
-
-
Save rayvinly/27e1cc51efc3a1015a1e to your computer and use it in GitHub Desktop.
Massive View Did Load
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
class ViewController: UITableViewController | |
{ | |
override func viewDidLoad() | |
{ | |
super.viewDidLoad() | |
let currentUser = userManager.loggedInUser() | |
if let currentUser = currentUser { | |
var followerPosts = [Post]() | |
let followers = userManager.followersForUser(currentUser) | |
for follower in followers { | |
postManager.fetchPostsForUser(follower) { (posts: [Post]?, error: ErrorType?) -> () in | |
if let error = error { | |
self.showAlert(error) | |
} else if let posts = posts { | |
followerPosts += posts | |
} | |
if follower == followers.last! { | |
self.recentPosts = Array(followerPosts.sort { $0 > $1 }[0...4]) | |
self.tableView.reloadData() | |
self.loginButton.hidden = true | |
} | |
} | |
} | |
} else { | |
recentPosts = | |
tableView.reloadData() | |
loginButton.hidden = false | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment