0

The code where the app exactly crashes is

NSString *phone, *phone_personal, *phone_business;
for(CFIndex i = 0; i < ABMultiValueGetCount(phones); i++) {
            mobileLabel = (NSString*)ABMultiValueCopyLabelAtIndex(phones, i);
            if([mobileLabel isEqualToString:(NSString *)kABPersonPhoneMainLabel]){
                phone = [(NSString*)ABMultiValueCopyValueAtIndex(phones, i) retain];
            }
            else{
                phone=@"(null)";
            }

            if([mobileLabel isEqualToString:(NSString *)kABPersonPhoneMobileLabel]){
                phone_personal = [(NSString*)ABMultiValueCopyValueAtIndex(phones, i)retain];
            }
            else{
                phone_personal=@"(null)";
            }

            if ([mobileLabel isEqualToString:(NSString*)kABPersonPhoneIPhoneLabel]){
                phone_business = [(NSString*)ABMultiValueCopyValueAtIndex(phones, i)retain];
            }
            else{
                phone_business=@"(null)";
            }

            [mobileLabel release];
        }
   CFRelease(phones);

First I am reading the all the phone numbers from the addressbook and then adds the phone numbers to the array arrayofnumbersandmeamsil.

 if (!([phone isEqualToString:@"(null)"]|| phone == nil || phone.length ==0)){
           [arrayofnumbersandmeamsil addObject:phone];
        }
        if (!([phone_personal isEqualToString:@"(null)"]|| phone_personal == nil || phone_personal.length ==0)) {
            [arrayofnumbersandmeamsil addObject:phone_personal];
        }
        if (!([phone_business isEqualToString:@"(null)"]|| phone_business == nil || phone_business.length ==0)) {
            [arrayofnumbersandmeamsil addObject:phone_business];
       }

My problem is my app is crashing on iPhone 4 and working fine on iPhone 3gs both have iOS 6.1.3. I know the issue is related to the initialization of phone,phone_personal,phone_business.

Issue is regarding the memory release. when i release mobileLabel using

[mobileLabel release];

and release phones using

CFRelease(phones);

Then it crashes and without releasing it shows the memory leak. How to handle this ?

1 Answers1

0

replacing

CFRelease(phones);

With

if(phones){
CFRelease(phones);
}

Solved my issue. Hope it helps someone.