ABAddressBookCopyArrayOfAllPeopleInSource return "0" object?

650 Views Asked by At

I'm trying to get contacts for specific Source but it is return to me 0 object.

Like u see if the source have Groups it will be add to array , but if there is no groups i just need to know number of contact in this source "for Example Google ,Facebook,.."

for (CFIndex i = 0; i < CFArrayGetCount(allSources); i++)
    {
        ABRecordRef aSource = CFArrayGetValueAtIndex(allSources,i);

        // Fetch all groups included in the current source
        CFArrayRef result = ABAddressBookCopyArrayOfAllGroupsInSource (myAddressBook, aSource);

        // The app displays a source if and only if it contains groups
        if (CFArrayGetCount(result) > 0)
        {
            NSMutableArray *groups = [[NSMutableArray alloc] initWithArray:(NSArray *)result];

            // Fetch the source name
            NSString *sourceName = [self nameForSource:aSource];
            //Create a MySource object that contains the source name and all its groups
            MySource *source = [[MySource alloc] initWithAllGroups:groups name:sourceName];

            // Save the source object into the array
            [list addObject:source];
            [source release];
            [groups release];
        }
        else
        {

            CFArrayRef result= ABAddressBookCopyArrayOfAllPeopleInSource(myAddressBook, aSource);

        }

        CFRelease(result);
    }
0

There are 0 best solutions below