Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy the addressbook can not remain up-to-date with ios?
    primarykey
    data
    text
    <p>I'm writing a custom addressbook app in ios and I use a singleton addressbookRef.</p> <p>Here is my operation steps:</p> <pre><code>+ (ABAddressBookRef) sharedAddressBook { static ABAddressBookRef ref = nil; if ( ref == nil ) { ref = ABAddressBookCreate(); } return ( ref ); } </code></pre> <p>step1: Open my addressbook app</p> <pre><code> ABAddressBookRef addressBook = [ABAddressBook sharedAddressBook]; ABRecordRef person = ABAddressBookGetPersonWithRecordID( addressBook, 83 ); NSString* name= ABRecordCopyValue(person,kABPersonFirstNameProperty); NSLog(@"%@",name); </code></pre> <p>console print "aaa".</p> <p>step2:</p> <p>quit my app(enterBackground, not kill), change the "aaa" person name to "bbb" by using the system dialer.</p> <p>step3:</p> <p>open my app(enterForeground), do the same thing</p> <pre><code>ABAddressBookRef addressBook = [ABAddressBook sharedAddressBook]; ABRecordRef person = ABAddressBookGetPersonWithRecordID( addressBook, 83 ); NSString* name= ABRecordCopyValue(person,kABPersonFirstNameProperty); NSLog(@"%@",name); </code></pre> <p>console print "aaa".</p> <p><strong>My question is</strong></p> <p>1.Why the console print "aaa", not "bbb" when used the old addressBookRef? When i change the [ABAddressBook sharedAddressBook] to ABAddressBookCreate(), everything seems to be ok. Why the old addressBookRef can not keep up-to-date?</p> <p>2.Should I need do ABAddressBookCreate() at enterForeground everytime?</p> <p>3.is the recordID changed when I edit the person info? I suspect.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload