Created
July 15, 2015 08:31
-
-
Save LeiHao0/b5e717a4cc0e01b6d11a to your computer and use it in GitHub Desktop.
exchange people's First and Last Name in Mac OSX Contacts
This file contains hidden or 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
| import AddressBook | |
| let addressBook = ABAddressBook.sharedAddressBook() | |
| let firstKey = "First" | |
| let lastKey = "Last" | |
| for people in addressBook.people() { | |
| if let p = people as? ABPerson { | |
| let f: AnyObject? = p.valueForKey(firstKey) | |
| let l: AnyObject? = p.valueForKey(lastKey) | |
| p.setValue(l, forKey: firstKey) | |
| p.setValue(f, forKey: lastKey) | |
| } | |
| } | |
| addressBook.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment