gpt4 book ai didi

ios - 调用函数 'ABRecordCopyValue' 返回一个保留计数为 +1 的 corefoundation 对象

转载 作者:可可西里 更新时间:2023-11-01 17:08:49 24 4
gpt4 key购买 nike

我的项目中有以下代码

- (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 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16667997/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com