Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-21-2011, 09:12 AM   #1 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 1
moshem is on a distinguished road
Default ABAddressBookRegisterExternalChangeCallback provides stale data

my app registers the callback once

Code:
    notificationAddressBook = ABAddressBookCreate();

	ABAddressBookRegisterExternalChangeCallback(notificationAddressBook, MyAddressBookExternalChangeCallback, self);
then in my callback

Code:
    void MyAddressBookExternalChangeCallback (ABAddressBookRef notifyAddressBook,CFDictionaryRef info,void *context)
	{
		 NSLog(@"in MyAddressBook External Change Callback");
		 
		 ABAddressBookRevert(notifyAddressBook);		 
		 	 
		 CFArrayRef peopleRefs = ABAddressBookCopyArrayOfAllPeopleInSource(notifyAddressBook, kABSourceTypeLocal);
		 
		 CFIndex count = CFArrayGetCount(peopleRefs);
		 NSMutableArray* people = [NSMutableArray arrayWithCapacity:count];
		 for (CFIndex i=0; i < count; i++) {
		    ABRecordRef ref = CFArrayGetValueAtIndex(peopleRefs, i);
		    ABRecordID id_ = ABRecordGetRecordID(ref);
		    TiContactsPerson* person = [[[TiContactsPerson alloc] _initWithPageContext:[context executionContext] recordId:id_ module:context] autorelease];
		    NSLog(@"name: %@", [person valueForKey:@"firstName"]);
		    NSLog(@"phone: %@", [person valueForKey:@"phone"]);
		    NSLog(@"modified: %@", [person valueForKey:@"modified"]);
		    [people addObject:person];
		 } 

		 CFRelease(peopleRefs);
	}
when adding a new contact the event is triggered fine, and the data is up-to-date in the first addition and the second and third... the problem is with editing an existing contact details.

the first time the event is triggered the data is true to the last update (I changed the phone number of one contact in the iphone address book), then I switch to the app and get the latest update. then I switch back to the address book make another change, switch to my app and get another event... this time the data is stale, the latest changes are not reflected.

I tried releasing the addressbook instance and run another ABAddressBookCreate() but it did not help either.

any ideas ?
moshem is offline   Reply With Quote
Reply

Bookmarks

Tags
addressbook, callback, event, iphone

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 398
14 members and 384 guests
7twenty7, chiataytuday, cristofercolmbos, dedeys78, fiftysixty, gmarro, iOS.Lover, jonathandeknudt, Matrix23, raymng, stanny, tymex, UMAD, xerohuang
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,669
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, dedeys78
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:12 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0