I am trying to access all the first name value field from the address book. I am using this code for this
CFStringRef firstName = ABRecordCopyValue(aSource, kABPersonFirstNameProperty);
first_name=[NSString stringWithFormat:@"%@",firstName];
CFRealease(firstname)
I am not using ARC. So i need to CFRealease(firstname) at the end. But in my code when i add CFRealease(firstname) my app crashes at this point and without this the app works fine.
But when i try to analyse my app by using analyzer it says object Leaked: object allocated and stored into 'firstname' is not refrenced later in the execution path and has a retain count of +1.
Case is same for midname and last name whose code are given below.
CFStringRef midname = ABRecordCopyValue(aSource, kABPersonMiddleNameProperty);
mid_name=[NSString stringWithFormat:@"%@",midname];
CFRelease(midname);
CFStringRef lastName = ABRecordCopyValue(aSource, kABPersonLastNameProperty);
last_name=[NSString stringWithFormat:@"%@",lastName];
CFRelease(lastName);
Please tell where i am doing it wrong. Thanks in advance.