Loading contacts from iPhone crashes in Swift
问题 I am trying to load the contacts for my App. It is working fine in Simulator. But crashing in iPhone. The code I am using: 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 != "") { println("found \(currentContactName).") } } } This