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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 02-25-2010, 07:32 AM   #1 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 17
Default How to get GROUP CODE from recordID ??

i'd want to find group code..


ABAddressBookRef addressBook = ABAddressBookCreate();
CFIndex nPeople = ABAddressBookGetPersonCount(addressBook);
CFIndex nGroup = ABAddressBookGetGroupCount(addressBook);
CFArrayRef grpval= ABAddressBookCopyArrayOfAllGroups(addressBook);
CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);

myList = [[NSMutableArray alloc] init];


// -->

NSNumber *recordId;
ABRecordRef recordGroupID;
NSString *contactCompany;

for(int i = 0 ; i < nPeople ; i++)
{
ref = CFArrayGetValueAtIndex(allPeople, i);

recordId = [NSNumber numberWithInteger:ABRecordGetRecordID(ref)];
recordGroupID = ABAddressBookGetGroupWithRecordID(addressBook, recordId);
contactCompany = (NSString *)ABRecordCopyValue(ref, kABPersonOrganizationProperty);

NSLog(@"record id is %@",recordId);
NSLog(@"record group id is %@",recordGroupID);
NSLog(@"Company: %@", contactCompany);
}

but, recordGroupID is not working.. there is no ERROR, but one alert.
"Passing argument 2 of 'ABAddressBookGetGroupWithRecordID' makes
integer from pointer without cast"
how i fix this ??

NSLog shows :

(gdb) continue
2010-02-25 21:30:15.433 IndexedSectionTable[5028:207] record id is 2
2010-02-25 21:30:15.434 IndexedSectionTable[5028:207] record group id is (null)
2010-02-25 21:30:15.435 IndexedSectionTable[5028:207] Company: friends > 02
Current language: auto; currently objective-c
.
.
.

groupCode is NULL.. why ??
BobbyJeyChoi is offline   Reply With Quote
Old 02-27-2010, 05:39 AM   #2 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 17
Default ah~

soved this problem !
BobbyJeyChoi is offline   Reply With Quote
Old 02-27-2010, 10:12 PM   #3 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 1
Default

recordId should be an NSInteger
so


ABAddressBookRef addressBook = ABAddressBookCreate();
CFIndex nPeople = ABAddressBookGetPersonCount(addressBook);
CFIndex nGroup = ABAddressBookGetGroupCount(addressBook);
CFArrayRef grpval= ABAddressBookCopyArrayOfAllGroups(addressBook);
CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);

myList = [[NSMutableArray alloc] init];


// -->

--> NSInteger recordId;
ABRecordRef recordGroupID;
NSString *contactCompany;

for(int i = 0 ; i < nPeople ; i++)
{
ref = CFArrayGetValueAtIndex(allPeople, i);

--> recordId = ABRecordGetRecordID(ref);
recordGroupID = ABAddressBookGetGroupWithRecordID(addressBook, recordId);
contactCompany = (NSString *)ABRecordCopyValue(ref, kABPersonOrganizationProperty);

NSLog(@"record id is %@",recordId);
NSLog(@"record group id is %@",recordGroupID);
NSLog(@"Company: %@", contactCompany);
}

Last edited by martinkpo12; 02-27-2010 at 10:22 PM.
martinkpo12 is offline   Reply With Quote
Old 02-28-2010, 06:25 AM   #4 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 17
Default

ah~~~~!! thanks to reply!!! it works.
BobbyJeyChoi is offline   Reply With Quote
Reply

Bookmarks

Tags
group, iphone, recordid, sdk

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: 239
16 members and 223 guests
@sandris, ADY, Alsahir, dacapo, Dani77, djohnson, HemiMG, jansan, JasonR, MarkC, mer10, prchn4christ, ryandb2, timle8n1, tomtom100
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,762
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

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