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

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

python - Django-easy-pdf: xhtml2pdf reporting reportlab 2.2+ is required, but 3.0 installed -

collision detection - C++ library for mesh to mesh intersection: what is available? -