问题描述
我正在使用此代码在应用中显示联系人.
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];
}
...我有泄漏:
我发现一些开发人员的帖子声称这是SDK中的错误,并且已经提交了错误.有人可以确认吗?或指向正确的方向.
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.
推荐答案
我知道这违反逻辑,也违反您所知道的一切,但是请相信我.注释掉释放选择器的行;
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
这很可能是Apple SDK中的错误
It's most likely a bug in the Apple SDK
这篇关于使用ABPeoplePickerNavigationController发生内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!