ios - Why i can't get contents of adressbook -


i trying content of adressbook these codes.

abaddressbookref addressbook = abaddressbookcreate();  if (addressbook != nil) {     nslog(@"succesful.");        nsarray *allcontacts = (__bridge_transfer nsarray                             *)abaddressbookcopyarrayofallpeople(addressbook);     nsuinteger = 0;     nslog(@"countt=%lu",(unsigned long)[allcontacts count]); } 

i succesful log count "0", use simulator , added contacts in test. ios 7 , xcode 5.

i glad take advice or help.

the problem test nil meaningless. if have not been granted access user address book, result of abaddressbookcreate() still non-nil. useless!

so, moral is: test see whether have been granted access (abaddressbookgetauthorizationstatus) and, if access has been neither granted nor denied, request formally (abaddressbookrequestaccesswithcompletion).


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -