ios – 调用函数’ABRecordCopyValue’返回一个带有1个保留计数的corefoundation对象

ios – 调用函数’ABRecordCopyValue’返回一个带有1个保留计数的corefoundation对象,第1张

概述我的项目中有以下代码 - (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person { [popContactsForm dismissPopo 我的项目中有以下代码

- (BOol)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker      shouldContinueAfterSelectingPerson:(ABRecordRef)person {    [popContactsForm dismisspopoverAnimated:YES];    [ssemailvc setname: (Nsstring *)ABRecordcopyValue(person,kABPersonFirstnameProperty)];            ABMultiValueRef emails = (Nsstring *)ABRecordcopyValue(person,kABPersonEmailProperty);    if (ABMultiValueGetCount(emails)>0) {        [ssemailvc setEmail:(Nsstring *)ABMultiValuecopyValueAtIndex(emails,0)];    }else [ssemailvc setEmail:@""];    CFRelease(emails);    [peoplePicker dismissModalVIEwControllerAnimated:YES];          [popEmailForm setPopoverContentSize:CGSizeMake(350.0,225.0)];    return NO;}

我收到了警告

1.call to function ‘ABRecordcopyValue’ returns a corefoundation object with a +1 retain count
2.object leaked:allocated object is not referenced later in the execution and has a retain count of +1

请告诉我如何克服这个问题

解决方法 如果使用ARC,则可以使用桥接转换:

CFStringRef name = (CFStringRef)ABRecordcopyValue(person,kABPersonFirstnameProperty);[ssemailvc setname:(__brIDge Nsstring*)name];CFRelease(name);

或桥接转移:

Nsstring * name = (__brIDge_transfer Nsstring *)ABRecordcopyValue(person,kABPersonFirstnameProperty);[ssemailvc setname:name];

如果您使用的是MRC:

CFStringRef name = (CFStringRef)ABRecordcopyValue(person,kABPersonFirstnameProperty);[ssemailvc setname:(Nsstring*)name];CFRelease(name);
总结

以上是内存溢出为你收集整理的ios – 调用函数’ABRecordCopyValue’返回一个带有1个保留计数的corefoundation对象全部内容,希望文章能够帮你解决ios – 调用函数’ABRecordCopyValue’返回一个带有1个保留计数的corefoundation对象所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1017682.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存