iphone addressbook - getting null item in ABAddressBookGetPersonWithRecordID

前端 未结 1 1385
温柔的废话
温柔的废话 2021-01-02 17:02

I\'m really struggling with ABAddressBookGetPersonWithRecordID at the moment. I am saving an ID, and then trying to call it back up again. Currently im doing something simpl

相关标签:
1条回答
  • 2021-01-02 17:18

    NSNumber is an object, not an integer.

    To insert an NSNumber object into a format string (such as for NSLog), you should use %@ (not %d).

    NSNumber *recordId = [NSNumber numberWithInteger:ABRecordGetRecordID(person)];
    NSLog(@"record id is %@",recordId);
    

    Similarly, if you have the recordID in an NSNumber object, you can get the integer value using integerValue:

    ABRecordRef person = ABAddressBookGetPersonWithRecordID(ab,recordId.integerValue);
    
    0 讨论(0)
提交回复
热议问题