1

When I try to load the table view with the list of contacts, it is not showing for the first time. But if I try Pull-To-Refresh or go to some view and come back to table view controller, the contacts are loading and showing perfectly. Here is the code:

func getContactNames()
{    
    let allContacts = ABAddressBookCopyArrayOfAllPeople(addressBookRef).takeRetainedValue() as Array
    for record in allContacts {
        let currentContact: ABRecordRef = record
        let currentContactName = ABRecordCopyCompositeName(currentContact)?.takeRetainedValue()
            as? String

        if(currentContactName != nil) {
            self.arrFriendsList.append(currentContactName! as String)
        }
    }

    // For alphabatically arranging
    self.arrFriendsList = self.arrFriendsList.sorted { $0.localizedCaseInsensitiveCompare($1) == NSComparisonResult.OrderedAscending }

    self.arrFilteredTableData = self.arrFriendsList
    self.tblView.reloadData()
}

I am calling this function in viewDidLoad method. Any idea for solution? Thanks in advance :)

AAA
  • 1,957
  • 4
  • 23
  • 42

0 Answers0