开发者

Why is this generating a warning?

开发者 https://www.devze.com 2023-02-24 04:26 出处:网络
ABMutableMultiValueRef *address = (NSString *)ABRecordCopyValue(thisPerson, kABPersonAddressProperty);
ABMutableMultiValueRef *address = (NSString *)ABRecordCopyValue(thisPerson, kABPersonAddressProperty);
for (CFIndex i=0; i < ABMultiValueGetCount(address); i++) {
    CFDictionaryRef dict = ABMultiValueCopyValueAtIndex(address, i);

The code works but ge开发者_StackOverflownerates a warning. Any clue?

Warning: FirstViewController.m:46: warning: initialization from incompatible pointer type


I believe you're getting a warning because you're assigning an NSString* value to a ABMutableMultiValueRef* variable. You should only assign a pointer variable to a pointer of the same type.


ABMutableMultiValueRef is a CFTypeRef, so perhaps casting the result of ABRecordCopyValue to CFString instead of NSString would be the simple solution.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号