國家code和區號計算

2021-09-08 04:01:35 字數 1055 閱讀 1442

找到了

libphonenumber-ios

標準化**號碼庫

這個類庫,能夠方便自己來使用。

以下是我在專案中的詳細使用:

1.首先定義了2個陣列

countrynames = [nsarray arraywithobjects:@"中國",@"香港地區",@"澳門地區",@"台灣地區",@"美國",@"日本", nil];

countrycodes = [nsarray arraywithobjects:@"cn",@"hk", @"mo", @"tw", @"us",@"jp", nil];

在已知code情況下,能夠通過

- (nsnumber*)getcountrycodeforregion:(nsstring*)regioncode;

這種方法來實現相應的區號

2.在cell來實現

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath

cell.textlabel.text = [countrynames objectatindex:indexpath.row];

nbphonenumberutil *phoneutil = [nbphonenumberutil sharedinstance];

nsnumberformatter* numberformatter = [[nsnumberformatter alloc] init];

cell.detailtextlabel.text = [numberformatter stringfromnumber:[phoneutil getcountrycodeforregion:[countrycodes objectatindex:indexpath.row]]];

return cell;

}

這裡要把nsnumber轉成nsstring。

最後感謝norn。

輸出500個連續的帶國家區號的長電話號碼

周海漢 文 2009.10.22 因為要批量處理 號碼,需要文字一行乙個 1.bash 處理,很直接 zhouhh p ssw 2 vi for.sh bin sh for x 8601060000000 x 8601060000500 x do echo x done zhouhh p ssw 2...

HTML pre標籤和code標籤

預格式化標籤 將字元設定為等寬字元的標籤 在html檔案中需要顯示一些比如 這種符號時需要使用到實體化字元 doctype html html head title 預格式化 title meta charset utf 8 meta name viewport content width devi...

CODE 1015 計算器的改良

題意是求解乙個一元一次方程組,只包含小寫字母,數字,求出最後的解即可。負號還可以做減號。我是用x儲存變數前的係數,y儲存整數的結果,等於放到等式一邊來考慮。include include int main 是字母的話 else ans ans 10 s 0 0 是數字 for int i 1 i a...