ABRecordCopyValue中的内存泄漏

时间:2012-11-08 04:54:16

标签: iphone ios6 abaddressbook

我正在构建一个应用程序,要求我从联系人中选择名字和姓氏。在使用Build Analyzer运行时,我在这段代码中遇到了内存泄漏。

ABMutableMultiValueRef fName = ABRecordCopyValue(person, kABPersonFirstNameProperty);
ABMutableMultiValueRef lName = ABRecordCopyValue(person, kABPersonLastNameProperty);    
if(fName){
    self.firstNameText.text = fName;
}
if (lName) {
    self.lastNameText.text = lName;
}
CFRelease(fName);
CFRelease(lName);

我真的厌倦了修复但却无法修复它。请帮助我。

任何形式的帮助都会受到高度关注。

提前致谢!!

1 个答案:

答案 0 :(得分:-3)

您好,这是委托方法。

in - (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person方法可以检索任何用户信息  比如kABPersonFirstNameProperty作为名字,kABPersonLastNameProperty作为姓氏属性

  - (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker {
// assigning control back to the main controller
[self dismissModalViewControllerAnimated:YES];
}

  - (BOOL)peoplePickerNavigationController: (ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person {
NSString *firstname=(NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
Usernametf.text=firstname;
//  NSMutableDictionary *dict=[[NSMutableDictionary alloc] initWithObjectsAndKeys:firstname,@"FirstName", nil];
//[selectedemailArray addObject:dict];
   // NSLog(@"\n array is %@",selectedemailArray);


//[objDatabase insertArray:selectedemailArray forTable:@"EmailList"];
//[objDatabase insertDictionary:dict forTable:@"EmailList"];
//    [dict release];
//    dict =nil;

// remove the controller
[self dismissModalViewControllerAnimated:YES];
return NO;

}

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{
return NO;
}

告诉我工作与否...... !!!!

快乐的编码!!!!!