كيف يمكنني الحصول على عدد الأشخاص من مصادر ExchentalGal باستخدام AbaddressBookCopyarrayOfallPeopleInsourceWithsorting ()

StackOverflow https://stackoverflow.com/questions/5062968

سؤال

أحاول الحصول على أشخاص في ثلاثة مصادر (1 مصدر موبيليم ومصادر 2 * exchentalgal) من دليل iOS 4.
يعرض بيان NSLOG دائما 0 شخصا ل Exchentalgal، ولكن يعيد عدد الأشخاص من الناس إلى MobileMe.
بعد الحصول على جميع المصادر من دفتر عناوين iOS باستخدام Abaddressbookcopyarrayofallsourcesourcesourcesourcesourcesourcesourcesourcesourcesourcesource

هل أنا أستخدم abaddressbookcopyarrayofallpleinsourcewithsortering بشكل صحيح؟
تتوقع عدد من جميع الناس في مصادر العناوين المختلفة.
giveacodicetagpre.

تحرير Feb24: يبدو وكأنه رمز يعمل، ولكن لدي مشكلة في الحصول على الناس العد من exhangegals.
هل تم استرجاع Anyoune أشخاصا بنجاح من Exchentalgal؟
مصدر موبيليم يعد عد الشعب.
هنا هو سجل من وحدة التحكم:
giveacodicetagpre.

هل كانت مفيدة؟

المحلول

Try Using:

ABRecordRef sourceWithType (ABSourceType mySourceType)
{
ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef sources = ABAddressBookCopyArrayOfAllSources(addressBook);
CFIndex sourceCount = CFArrayGetCount(sources);
ABRecordRef resultSource = NULL;
for (CFIndex i = 0 ; i < sourceCount; i++) {
    ABRecordRef currentSource = CFArrayGetValueAtIndex(sources, i);
    ABSourceType sourceType = [(NSNumber *)ABRecordCopyValue(currentSource, kABSourceTypeProperty) intValue];
    if (mySourceType == sourceType) {
        resultSource = currentSource;
        break;
    }
}

return resultSource;
}

ABRecordRef localSource()
{
    return sourceWithType(kABSourceTypeLocal);
}

ABRecordRef exchangeSource()
{
     return sourceWithType(kABSourceTypeExchange);
}

ABRecordRef mobileMeSource()
{
     return sourceWithType(kABSourceTypeMobileMe);
}

You might find this helpful :abaddressbook-absource-and-absourcetype

نصائح أخرى

Are the people you're expecting to return actually in your addressbook? You shouldn't expect ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering() to return the entire GAL. That would be massive. You should only expect it to return a subset of ABAddressBookCopyArrayOfAllPeople().

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top