gpt4 book ai didi

ios - 使用 ABPeoplePickerNavigationController 和 Core Data 的应用程序中出现奇怪的 48 字节泄漏

转载 作者:行者123 更新时间:2023-11-29 04:44:57 24 4
gpt4 key购买 nike

此时我不确定这些泄漏是否与 CoreData 相关或什么,因为我在同一应用程序的其他部分中因明显不同的原因经历了 48 字节 strdup 泄漏 - 请参阅我的其他问题:another stack overflow question

但是,假设没有关系,我有一个 viewController,它根据用户选择的选项,呈现一个 ABPeoplePicker。然而,无论是否选择联系人,似乎仅仅通过呈现选择器我就会泄漏。

用于呈现选择器的代码是:

- (void)showPeoplePickerController
{
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.displayedProperties = [NSArray arrayWithObject:[NSNumber numberWithInt:kABPersonEmailProperty]];
picker.peoplePickerDelegate = self;
[self presentModalViewController:picker animated:YES];
[picker release];
}

委托(delegate)方法实现如下:

- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker
{
[self dismissModalViewControllerAnimated:YES];
}

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
{
return YES;
}

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier
{
ABMultiValueRef emails = ABRecordCopyValue(person, property);

if(userEmailString)
[userEmailString release];

userEmailString = (NSString*)ABMultiValueCopyValueAtIndex(emails, identifier);

CFRelease(emails);

[[NSNotificationCenter defaultCenter] postNotificationName:@"recipientEmailDidUpdateNotification"
object:self];
return NO;
}

为了以防万一,userEmailString 是 Controller 保留的 NSString 属性(这意味着我也可以使用 self.userEmailString = blah)。

这些是 Instruments 报告泄漏的屏幕截图。但请注意,它认为选择器没有被释放,尽管我在呈现它后调用释放。我也尝试过使用 CFRelease() 来代替......但仍然是一样的。

enter image description here

enter image description here

enter image description here

最佳答案

无论如何,是的..泄漏在 SDK 中。

关于ios - 使用 ABPeoplePickerNavigationController 和 Core Data 的应用程序中出现奇怪的 48 字节泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9790719/

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