libPhoneNumber-iOS icon indicating copy to clipboard operation
libPhoneNumber-iOS copied to clipboard

get error when call NBPhoneNumberUtil parse method

Open xilibro opened this issue 7 years ago • 5 comments

`

 +(bool)checkPhoneNumber: (NSString *)phone {

    NBPhoneNumberUtil *phoneUtil = [[NBPhoneNumberUtil alloc] init];

    NSError *error = nil;
    NBPhoneNumber *phoneNumber = [phoneUtil parse:@"14155552671" defaultRegion:@"US" error:&error];
    NSLog(@"- isValidNumber [%@]", [phoneUtil isValidNumber:phoneNumber] ? @"YES" : @"NO");

    if (error == nil) {
        return [phoneUtil isValidNumber: phoneNumber];
    } else {
        NSLog(@"Error : %@", [error localizedDescription]);
    }

    return false;
}

` phoneUtil parse make application crash. and i got an error like below:

'NSInvalidArgumentException', reason: '-[__NSArrayI nb_safeArrayAtIndex:]: unrecognized selector sent to instance 0x60c0003e0800'

in NBPhoneMetadata.m line33

who can give me some help, thanks. libPhoneNumber-iOS (0.9.13)

xilibro avatar Dec 21 '17 09:12 xilibro

Getting the same issue. Did anyone get any solution to it?

navjotbedi avatar Feb 16 '18 08:02 navjotbedi

Same issue...

slebreton38 avatar Apr 18 '18 14:04 slebreton38

Found the solution in my case (no ARC project), I have to:

  • in PROJECT>TARGETS>myAppTarget>Build Settings>Other Linker Flags Add flag "-ObjC"
  • in PROJECT Pods>TARGETS>libPhoneNumber-iOS>Build Phases>Compile Sources Add Compiler Flags for each file "-fobjc-arc" Works perfect now.

slebreton38 avatar Apr 19 '18 13:04 slebreton38

I'm seeing this issue too

crash is in NBPhoneMetaData.m at line 33 _generalDesc = [[NBPhoneNumberDesc alloc] initWithEntry:[entry nb_safeArrayAtIndex:1]];

@slebreton38 your fix didnt make any difference to my app (even after cleaning and clearing derived data)

nitinalabur avatar Jul 11 '18 15:07 nitinalabur

Had same issue. Tried the "-fobjc-arc" solution above to no avail. I looked into the method nb_safeArrayAtIndex and XCode directed me to the file "NSArray+NBAdditions.h" which came in the submodule update folder. But the same file's .m was not listed in my compile sources. When I added the file "NSArray+NBAdditions.m" to project compile sources, the crash stopped happening. Cheers!

ice-cream-kid avatar Oct 13 '20 17:10 ice-cream-kid