Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to get GROUP CODE from recordID ??

BobbyJeyChoiBobbyJeyChoi Posts: 17Registered Users
edited February 2010 in iOS SDK Development
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 ??
Post edited by BobbyJeyChoi on
· ·

Replies

  • BobbyJeyChoiBobbyJeyChoi Posts: 17Registered Users
    edited February 2010
    soved this problem !
    · ·
  • martinkpo12martinkpo12 Posts: 1New Users
    edited February 2010
    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);
    }
    · ·
  • BobbyJeyChoiBobbyJeyChoi Posts: 17Registered Users
    edited February 2010
    ah~~~~!! thanks to reply!!! it works.
    · ·
Sign In or Register to comment.