HI, I am getting memory leak at NSObject allocation i.e.,
ContactDTO* contactDTO = [[ContactDTO alloc] init];
Code:
+(ContactDTO*) getContactDTOForId:(NSString*) contactId
{
NSString* homeMail =@"";
NSString* workMail=@"";
NSString *lastNameString=@"";
NSString *firstNameString=@"";
firstNameString = [AddressBookUtil getValueForProperty:kABPersonFirstNameProperty forContact:contactId];
lastNameString = [AddressBookUtil getValueForProperty:kABPersonLastNameProperty forContact:contactId];
ABRecordID contactIntId = [contactId intValue];
ABRecordRef person = ABAddressBookGetPersonWithRecordID(addressBook, contactIntId);
ABMultiValueRef emailMultiValue =(NSString *)ABRecordCopyValue(person, kABPersonEmailProperty);
for(CFIndex j=0;j<ABMultiValueGetCount(emailMultiValue);j++)
{
NSString* curentTypeLabel =(NSString *)ABMultiValueCopyLabelAtIndex(emailMultiValue,j);
if([curentTypeLabel isEqualToString:@"_$!<Home>!$_"]==YES)
{
NSString* currentEmail =(NSString *)ABMultiValueCopyValueAtIndex(emailMultiValue,j);
if([currentEmail isEqualToString:nil]==NO)
{
homeMail = [currentEmail copy];
}
}
if([curentTypeLabel isEqualToString:@"_$!<Work>!$_"]==YES)
{
NSString* currentEmail =(NSString *)ABMultiValueCopyValueAtIndex(emailMultiValue,j);
if([currentEmail isEqualToString:nil]==NO)
{
workMail = [currentEmail copy];
}
}
}
ContactDTO* contactDTO = [[ContactDTO alloc] init];
contactDTO.firstName = firstNameString;
contactDTO.lastName = lastNameString;
contactDTO.contactId = contactId;
contactDTO.homeEmail = homeMail;
contactDTO.workEmail = workMail;
return [contactDTO autorelease];
}