我正在構建一個應用程序,它要求我從iPhone AddressBook中的表的數據源中加載所有聯繫人。在運行ABRecordCopyValue的潛在內存泄漏
建立與分析
以下片斷
ABAddressBookRef addressBook = ABAddressBookCreate();
int nPeople = ABAddressBookGetPersonCount(addressBook);
CFRelease(addressBook);
for(int i=0; i < nPeople; i++){
//ABRecordRef person = [allPeople objectAtIndex:i];
NSString *name = @"";
if(ABRecordCopyValue([allPeople objectAtIndex:i], kABPersonFirstNameProperty) != NULL)
name = [[NSString stringWithFormat:@"%@", ABRecordCopyValue([allPeople objectAtIndex:i], kABPersonFirstNameProperty)] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
[dataSource addObject: name];
}
[allPeople release];
我得到一個潛在的內存泄漏的行
name = [[NSString stringWithFormat:@"%@", ABRecordCopyValue([allPeople objectAtIndex:i], kABPersonFirstNameProperty)] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
我真的累了的修復它,但無法。請幫助我。
任何形式的幫助都會被高度評價。
在此先感謝!
非常感謝vickink ......這個工作對我來說...:)......你救了我的一天 – devsri 2011-02-14 11:33:06
嘿能請你幫我在這如以及http://stackoverflow.com/questions/4991247/getting-warning-in-setting-delegate-for-abpeoplepickernavigationcontroller謝謝 – devsri 2011-02-14 11:41:12