Memory leak with ABPeoplePickerNavigationController?

*爱你&永不变心* 提交于 2019-12-31 02:14:11

问题


I'm using this code to display the contacts in an app.

- (IBAction) selectContact:(id)sender {

    ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
    picker.peoplePickerDelegate = self;

    NSArray *displayedItems = [NSArray arrayWithObjects:[NSNumber numberWithInt:kABPersonAddressProperty], nil];
    picker.displayedProperties = displayedItems;
    [self presentModalViewController:picker animated:YES];
    [picker release];
}

and there is a memory leak, according to instruments. Even if I cancel the person picker like this:

- (void) peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker {
    NSLog(@"peoplePickerNavigationControllerDidCancel");

    [self dismissModalViewControllerAnimated:YES];
}

... I got a leak:

I have found some posts of developers claiming that this is a bug in the SDK and that a bug has already been filed. Can someone confirm that? or point me in the right direction.


回答1:


I know this goes against logic, and against everything you know, but please trust me on this. Comment out the line that releases the picker;

//-- [picker release]; this line must be commented

It's most likely a bug in the Apple SDK




回答2:


Try updating your SDK to the most recent iOS version, and see if the leak still occurs. If it does, please file a bug through the developer center.



来源:https://stackoverflow.com/questions/5074684/memory-leak-with-abpeoplepickernavigationcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!