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

时间:2012-03-20 16:20:06

标签: ios cocoa-touch instruments abpeoplepickerview addressbookui

此时我不确定这些泄漏是否与CoreData相关或者是什么,因为我在同一个应用程序的其他部分遇到了48字节的strdup泄漏,原因显然不同 - 请参阅我的另一个问题:{{3 }}

但是,假设没有关系,我有一个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];
}

委托方法实现如下:

- (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是控制器的保留NSString属性(意味着我也可以使用self.userEmailString = blah)。

这些是来自Instruments的屏幕截图,报告泄漏。但请注意,它认为它的选择器没有被释放,尽管我在发布之后正在调用它。而且我也尝试过做CFRelease()而不是......但仍然是一样的。

enter image description here

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:1)

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