2

我正在构建一个应用程序,要求我从联系人中选择名字和姓氏。在使用 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);

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

任何形式的帮助都会受到高度评价。

提前致谢!!

4

1 回答 1

-3

您好,这是委托方法。

在 - (BOOL)peoplePickerNavigationController: (ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person 方法中,您可以检索任何用户信息,例如 kABPersonFirstNameProperty for first name, kABPersonLastNameProperty for last name property

  - (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;
}

让我知道它是否有效..!!!!

编码快乐!!!!

于 2012-11-08T06:50:17.413 回答