I want to retrieve the birth date from address book & display it in table view cell. I can retrieve the birth date from address book but when I show it in table view cell , app crashes.
Here is my code
// in viewDidLoad
birthdateString = [ContactDetails getBirthDate:record];
+(NSString*)getBirthDate:(ABRecordRef)record{
NSString *birthdateString=[(NSDate*)ABRecordCopyValue(record, kABPersonBirthdayProperty) description];
NSArray *array=[birthdateString componentsSeparatedByString:@" "];
birthdateString=[array objectAtIndex:0] ;
NSLog(@"birthDay: %@",birthdateString);
return birthdateString;
}
// in cellForRowAtIndexPath
cell=[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CELL_ID] autorelease];
cell.detailTextLabel.text=birthdateString;
Console log when NSZombieEnabled
*** -[CFString isEqualToString:]: message sent to deallocated instance 0x6eb5520
Any kind help is appreciated.
Its not the full code so cant tell , but check for nil value during debugging . There is some NSString which is not getting memory allocation.
Just got the answer
You are using brithdateString which was local and deallocated after the getBrithDate method was called