ios - NSString to NSNumber ignores initial zeros -


i converting nsstring nsnumber. problem if nsstring starts zeros converting nsnumber ignores initial zeros. know initial zeros doesn't mean want keep initial zeros because it's phonenumber in case.

here code:

nslog(@"test1: %@",tempphonenumber); nsnumberformatter *formatter=[[nsnumberformatter alloc] init]; [formatter setnumberstyle:nsnumberformatterdecimalstyle]; nsnumber *temppnonenumbernumber=[formatter numberfromstring:tempphonenumber]; nslog(@"test: %@",temppnonenumbernumber); 

if test1: 00966123456789 test: 966123456789

i want both same

nsnumber cannot keep initial zeros.

if want keep zeros, don't convert it nsnumber. phone numbers not numbers, there kept strings.

also note phonenumbers can contain other characters: +, * or #. these characters have special meaning (e.g. + @ beginning means same 00).


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -