From 725110ab6a67db6c112e73ef4d4fff180eb47222 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Wed, 2 Sep 2015 10:34:33 +0800 Subject: [PATCH] code order of loadContacts --- .../FriendsInContactsViewController.swift | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Yep/ViewControllers/FriendsInContacts/FriendsInContactsViewController.swift b/Yep/ViewControllers/FriendsInContacts/FriendsInContactsViewController.swift index 5c31e15d..1291f1cb 100644 --- a/Yep/ViewControllers/FriendsInContacts/FriendsInContactsViewController.swift +++ b/Yep/ViewControllers/FriendsInContacts/FriendsInContactsViewController.swift @@ -57,8 +57,12 @@ class FriendsInContactsViewController: BaseViewController { friendsTableView.rowHeight = 80 friendsTableView.tableFooterView = UIView() - addressBook.loadContacts{ [weak self] (contacts: [AnyObject]!, error: NSError!) in - if let contacts = contacts as? [APContact] { + addressBook.loadContacts { [weak self] (contacts: [AnyObject]!, error: NSError!) in + + if (error != nil) { + YepAlert.alertSorry(message: error.localizedDescription, inViewController: self) + + } else if let contacts = contacts as? [APContact] { var uploadContacts = [UploadContact]() @@ -76,27 +80,24 @@ class FriendsInContactsViewController: BaseViewController { //println(uploadContacts) - dispatch_async(dispatch_get_main_queue()) { + dispatch_async(dispatch_get_main_queue()) { [weak self] in self?.activityIndicator.startAnimating() } - friendsInContacts(uploadContacts, failureHandler: { [weak self] (reason, errorMessage) in + friendsInContacts(uploadContacts, failureHandler: { (reason, errorMessage) in defaultFailureHandler(reason, errorMessage) - dispatch_async(dispatch_get_main_queue()) { + dispatch_async(dispatch_get_main_queue()) { [weak self] in self?.activityIndicator.stopAnimating() } - }, completion: { [weak self] discoveredUsers in - dispatch_async(dispatch_get_main_queue()) { + }, completion: { discoveredUsers in + dispatch_async(dispatch_get_main_queue()) { [weak self] in self?.discoveredUsers = discoveredUsers self?.activityIndicator.stopAnimating() } }) - - } else if (error != nil) { - YepAlert.alertSorry(message: error.localizedDescription, inViewController: self) } } }