What’s the easiest way to programmatically (from within my app) get all items stored in the keychain?
It probably has something to do with SecItemCopyMatching(), but the documentation for that function is not very clear (and I failed to find a decent sample on the web).
SecItemCopyMatchingis the right call for that. First we build our query dictionary so that the items’ attributes are returned in dictionaries, and that all items are returned:As
SecItemCopyMatchingrequires at least the class of the returnedSecItems, we create an array with all the classes……and for each class, set the class in our query, call
SecItemCopyMatching, and log the result.In production code, you should check that the
OSStatusreturned bySecItemCopyMatchingis eithererrSecItemNotFound(no items found) orerrSecSuccess(at least one item was found).