For many years of my life I was an iOS Programmer. I worked in Objective-C, but Swift came out while I was working transitioning out of that area. Swift has always been a bit confusing for me, but I have a new complaint today. The amount of changes in Swift has caused a lot of online code to be out of date, and hard to parse.
The problem. I’m looking at my address book and I want to iterate through my contacts. I started by looking at ABAddressBook
, but it turns out that technology has been depricated. Then I started looking at CNContactStore
which is the new hotness. There are several fun methods on that object including unifiedMeContactWithKeys
which is pretty cool. It only returns my contact, not all contacts, but at least I was able to get it work. There is a similar function called
|
|
You try to pass in the truthy predicate and it rejects it. You need to actually use the
enumerateContacts()
method. Some examples mix strings and other types with keys and that causes problems. Just using a list of Keys worked. Here is the final code that worked:
|
|
I’m still working on the project and there is bunch more to do this, but this is a start and figured it was worth putting out there.