美文网首页
Swift-国家选择区号列表

Swift-国家选择区号列表

作者: 孤独的喵宝宝 | 来源:发表于2017-10-18 15:10 被阅读0次

网上只找到了oc 版的,swift的版没找到,所以就自己照着oc的改 成了swift的,然后改代码的时候遇见了很多坑,因为之前那份代码用的是uisearchbar. 然后因为说这个东西已经被遗弃了,所以就应的新的uiserachController,这个东西坑真的多··其他文章也有介绍,我就说说我自己遇到的,就是搜索框会往上便宜的问题,也就一行代码 自己注意一下

searchController.hidesNavigationBarDuringPresentation = false

这个代码的意思就是在打开搜索视图的时候隐藏导航栏,api里面上这么说的

99814D30-9DBF-4CA5-B6E7-239E443CF482.png

默认属性是true


10782DD9-3C5E-48D8-8F1C-56D10D82ACFB.png

直接上代码


//
//  ChonsenCountryViewController.swift
//  RegisUI
//
//  Created by Ender on 2017/10/16.
//  Copyright © 2017年 Chris. All rights reserved.
//

import UIKit

let CURR_LANG = NSLocale.preferredLanguages.first!
let LanguageisEnglish = "en-US".elementsEqual(CURR_LANG) || "en-CA".elementsEqual(CURR_LANG) || "en-GB".elementsEqual(CURR_LANG) || "en-CN".elementsEqual(CURR_LANG) || "en".elementsEqual(CURR_LANG)
//设置代理,用来往界面传值
protocol CountryCodeDelegate{
    func returnCountyrCode(countryCode:String)
    func returnCountryName(countryName:String)
}

class ChonsenCountryViewController: BasicViewController,UITableViewDataSource,UITableViewDelegate,UISearchBarDelegate,UISearchControllerDelegate,UISearchResultsUpdating {
    
    
    var delegate:CountryCodeDelegate! = nil
    var countryCodeTableView = UITableView();
    //搜索
    var searchController = UISearchController();
    //代码字典
    var sortedNameDict = Dictionary<String, NSArray>(); //代码字典
    var indexArray = Array<String>();//索引列表
    var searchResultValuesArray = NSMutableArray();//搜索结果集国家名
    var searchResultValuesCode = NSMutableArray();//搜索结果集国家区号
    
    
    
    override func viewDidLoad() {
        self.titleName = "选择分区号"
        super.viewDidLoad()
        //背景
        self.view.backgroundColor = UIColor.white
        createSubview()
        //注册cell
        self.countryCodeTableView.register(UITableViewCell.classForCoder(), forCellReuseIdentifier: "cellIdentifier1")
        self.countryCodeTableView.register(UITableViewCell.classForCoder(), forCellReuseIdentifier: "cellIdentifier2")
        
        // Do any additional setup after loading the view.
    }
    
    func createSubview(){
        searchResultValuesArray = NSMutableArray()
        let tableFrame = CGRect(x: 0, y: 66, width: self.view.bounds.size.width, height: self.view.bounds.size.height - 20)
        countryCodeTableView = UITableView(frame: tableFrame, style: .plain)
        self.view.addSubview(countryCodeTableView)
        countryCodeTableView.autoresizingMask = .flexibleWidth
        countryCodeTableView.delegate = self
        countryCodeTableView.dataSource = self
        countryCodeTableView.sectionIndexColor = UIColor.cyan
        
        
        
        //searchController
        searchController = UISearchController(searchResultsController: nil)
        searchController.dimsBackgroundDuringPresentation = false
        searchController.hidesNavigationBarDuringPresentation = false
        searchController.searchBar.delegate = self
        searchController.searchBar.backgroundColor = UIColor.white
        //searchController.searchBar.autocapitalizationType = .none
        searchController.delegate = self
        searchController.searchResultsUpdater = self
        self.definesPresentationContext = true
        searchController.searchBar.searchBarStyle = .minimal
        
        countryCodeTableView.tableHeaderView = self.searchController.searchBar
        //searchController.searchBar
        
        //加载plist文件
        let plistPathCh = Bundle.main.path(forResource: "sortedChname", ofType: "plist")
        
        
        if LanguageisEnglish {
            sortedNameDict = NSDictionary(contentsOfFile: plistPathCh!) as! [String : NSArray]
        }else{
            sortedNameDict = NSDictionary(contentsOfFile: plistPathCh!) as! [String : NSArray]
            
        }
        let arr = sortedNameDict.keys.sorted(){ $0 < $1 }
        indexArray = Array(arr)
        
    }
    //mark ----UISearchController
    //将搜索数据添加到搜索集
    func updateSearchResults(for searchController: UISearchController) {
        searchResultValuesCode.removeAllObjects()
        searchResultValuesArray.removeAllObjects()
        for array in sortedNameDict.values{
            //country list
            let arr = array.value(forKey: "country") as! Array<String>
            let arrCode = array.value(forKey: "code") as! Array<String>
            
            let Interval = 1
            for i in stride(from: 0, to: arr.count, by: Interval) {
                let val = arr[i]
                if (val.range(of: searchController.searchBar.text!) != nil){
                    searchResultValuesArray.add(val)
                    searchResultValuesCode.add(arrCode[i])
                }
            }
            
            
            
        }
        self.countryCodeTableView.reloadData()
    }
    //结束编辑
    func searchBarShouldEndEditing(_ searchBar: UISearchBar) -> Bool {
        return true
    }
    
    func searchBarShouldBeginEditing(_ searchBar: UISearchBar) -> Bool {
        return true
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    //mark - UITableView
    
    func numberOfSections(in tableView: UITableView) -> Int {
        if self.searchController.isActive {
            return 1
        }
        return sortedNameDict.keys.count
    }
    //the row in section
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if self.searchController.isActive {
            return searchResultValuesArray.count
        }
        return sortedNameDict[indexArray[section]]!.count
        
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 44
    }
    //cell
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        var cell:UITableViewCell! = nil
        if  self.searchController.isActive  {
            let ID2:String = "cellIdentifier2"
            cell = tableView.dequeueReusableCell(withIdentifier: ID2)!
            if cell == nil {
                cell = UITableViewCell(style: .value1, reuseIdentifier: ID2)
            }else{
                cell = UITableViewCell(style: .value1, reuseIdentifier: nil)
            }
           
            let index = indexPath.row
            if searchResultValuesArray.count > 0 {
                print(index)
                cell.textLabel?.text = searchResultValuesArray[index] as? String
                cell.detailTextLabel?.text = "+\(searchResultValuesCode[index])"
            }
            return cell
        } else {
            let ID1 = "cellIdentifier1"
            cell = tableView.dequeueReusableCell(withIdentifier: ID1)
            if cell == nil {
                cell = UITableViewCell(style: .value1, reuseIdentifier: ID1)
            }else{
                cell = UITableViewCell(style: .value1, reuseIdentifier: nil)
            }
            //初始化cell
            let section = indexPath.section
            let row = indexPath.row
            let countryCode = (sortedNameDict[indexArray[section]]?[row] as AnyObject).value(forKey: "country") as? String
            let code =  (sortedNameDict[indexArray[section]]?[row] as AnyObject).value(forKey: "code") as! String
            
            cell!.textLabel?.text = "\(countryCode!)"
            cell!.detailTextLabel?.text = "+" + code
            cell!.textLabel?.font = UIFont.boldSystemFont(ofSize: 16)
            return cell!
        }
    }
    //设置右侧索引
    func sectionIndexTitles(for tableView: UITableView) -> [String]? {
        if tableView == countryCodeTableView {
            return indexArray
        }else{
            return nil
        }
    }
    func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int {
        if tableView == countryCodeTableView {
            return index
        }else{
            return 0
        }
    }
    //设置header高度
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        if tableView == countryCodeTableView {
            if section == 0{
                return 30
            }
            return 30
        }else{
            return 0
        }
    }
    func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
        return indexArray[section]
    }
    //----选择国际获取代码,并用委托传值,
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let cell = tableView.cellForRow(at: indexPath)
        if self.searchController.isActive {
            print("searchBar")
            let areaCode = cell?.detailTextLabel?.text
            self.delegate?.returnCountryName(countryName: (cell?.textLabel?.text)!)
            self.delegate.returnCountyrCode(countryCode:areaCode!)
            self.dismiss(animated: true, completion: nil)
            self.dismiss(animated: true, completion: nil)
            self.searchController.searchBar.text = ""
        }else{
            self.delegate?.returnCountyrCode(countryCode: (cell?.detailTextLabel?.text)!)
            self.delegate?.returnCountryName(countryName: (cell?.textLabel?.text)!)
            self.dismiss(animated: true, completion: nil)
        }
    }
    
      
}

调用的代码


   let chonsenCountryCodeVC = ChonsenCountryViewController()
        chonsenCountryCodeVC.delegate = self
        self.present(chonsenCountryCodeVC, animated: true, completion: nil)

然后还有份plist文件,你新建一个plist文件,复制进去就可以了

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>A</key>
    <array>
        <dict>
            <key>country</key>
            <string>阿尔巴尼亚</string>
            <key>code</key>
            <string>355</string>
        </dict>
        <dict>
            <key>country</key>
            <string>阿尔及利亚</string>
            <key>code</key>
            <string>213</string>
        </dict>
        <dict>
            <key>country</key>
            <string>阿富汗</string>
            <key>code</key>
            <string>93</string>
        </dict>
        <dict>
            <key>country</key>
            <string>阿根廷</string>
            <key>code</key>
            <string>54</string>
        </dict>
        <dict>
            <key>country</key>
            <string>爱尔兰</string>
            <key>code</key>
            <string>353</string>
        </dict>
        <dict>
            <key>country</key>
            <string>埃及</string>
            <key>code</key>
            <string>20</string>
        </dict>
        <dict>
            <key>country</key>
            <string>埃塞俄比亚</string>
            <key>code</key>
            <string>372</string>
        </dict>
        <dict>
            <key>country</key>
            <string>爱沙尼亚</string>
            <key>code</key>
            <string>372</string>
        </dict>
        <dict>
            <key>country</key>
            <string>阿拉伯联合酋长国</string>
            <key>code</key>
            <string>971</string>
        </dict>
        <dict>
            <key>country</key>
            <string>阿鲁巴</string>
            <key>code</key>
            <string>297</string>
        </dict>
        <dict>
            <key>country</key>
            <string>阿曼</string>
            <key>code</key>
            <string>968</string>
        </dict>
        <dict>
            <key>country</key>
            <string>安道尔</string>
            <key>code</key>
            <string>376</string>
        </dict>
        <dict>
            <key>country</key>
            <string>安哥拉</string>
            <key>code</key>
            <string>244</string>
        </dict>
        <dict>
            <key>country</key>
            <string>安圭拉</string>
            <key>code</key>
            <string>1264</string>
        </dict>
        <dict>
            <key>country</key>
            <string>阿提瓜和巴布达</string>
            <key>code</key>
            <string>1268</string>
        </dict>
        <dict>
            <key>country</key>
            <string>澳大利亚</string>
            <key>code</key>
            <string>61</string>
        </dict>
        <dict>
            <key>country</key>
            <string>奥地利</string>
            <key>code</key>
            <string>43</string>
        </dict>
        <dict>
            <key>country</key>
            <string>阿塞拜疆</string>
            <key>code</key>
            <string>994</string>
        </dict>
    </array>
    <key>B</key>
    <array>
        <dict>
            <key>country</key>
            <string>巴巴多斯</string>
            <key>code</key>
            <string>1246</string>
        </dict>
        <dict>
            <key>country</key>
            <string>巴布亚新几内亚</string>
            <key>code</key>
            <string>675</string>
        </dict>
        <dict>
            <key>country</key>
            <string>巴哈马</string>
            <key>code</key>
            <string>1242</string>
        </dict>
        <dict>
            <key>country</key>
            <string>白俄罗斯</string>
            <key>code</key>
            <string>375</string>
        </dict>
        <dict>
            <key>country</key>
            <string>百慕大</string>
            <key>code</key>
            <string>1441</string>
        </dict>
        <dict>
            <key>country</key>
            <string>巴基斯坦</string>
            <key>code</key>
            <string>92</string>
        </dict>
        <dict>
            <key>country</key>
            <string>巴拉圭</string>
            <key>code</key>
            <string>595</string>
        </dict>
        <dict>
            <key>country</key>
            <string>巴林</string>
            <key>code</key>
            <string>973</string>
        </dict>
        <dict>
            <key>country</key>
            <string>巴拿马</string>
            <key>code</key>
            <string>507</string>
        </dict>
        <dict>
            <key>country</key>
            <string>保加利亚</string>
            <key>code</key>
            <string>359</string>
        </dict>
        <dict>
            <key>country</key>
            <string>巴西</string>
            <key>code</key>
            <string>55</string>
        </dict>
        <dict>
            <key>country</key>
            <string>北马里亚纳群岛</string>
            <key>code</key>
            <string>1670</string>
        </dict>
        <dict>
            <key>country</key>
            <string>贝宁</string>
            <key>code</key>
            <string>229</string>
        </dict>
        <dict>
            <key>country</key>
            <string>比利时</string>
            <key>code</key>
            <string>32</string>
        </dict>
        <dict>
            <key>country</key>
            <string>冰岛</string>
            <key>code</key>
            <string>354</string>
        </dict>
        <dict>
            <key>country</key>
            <string>博茨瓦纳</string>
            <key>code</key>
            <string>267</string>
        </dict>
        <dict>
            <key>country</key>
            <string>波多黎各</string>
            <key>code</key>
            <string>1787</string>
        </dict>
        <dict>
            <key>country</key>
            <string>波兰</string>
            <key>code</key>
            <string>48</string>
        </dict>
        <dict>
            <key>country</key>
            <string>玻利维亚</string>
            <key>code</key>
            <string>591</string>
        </dict>
        <dict>
            <key>country</key>
            <string>伯利兹</string>
            <key>code</key>
            <string>501</string>
        </dict>
        <dict>
            <key>country</key>
            <string>波斯尼亚和黑塞哥维那</string>
            <key>code</key>
            <string>387</string>
        </dict>
        <dict>
            <key>country</key>
            <string>不丹</string>
            <key>code</key>
            <string>975</string>
        </dict>
        <dict>
            <key>country</key>
            <string>布基纳法索</string>
            <key>code</key>
            <string>226</string>
        </dict>
        <dict>
            <key>country</key>
            <string>布隆迪</string>
            <key>code</key>
            <string>257</string>
        </dict>
    </array>
    <key>C</key>
    <array>
        <dict>
            <key>country</key>
            <string>朝鲜</string>
            <key>code</key>
            <string>850</string>
        </dict>
        <dict>
            <key>country</key>
            <string>赤道几内亚</string>
            <key>code</key>
            <string>240</string>
        </dict>
    </array>
    <key>D</key>
    <array>
        <dict>
            <key>country</key>
            <string>丹麦</string>
            <key>code</key>
            <string>45</string>
        </dict>
        <dict>
            <key>country</key>
            <string>德国</string>
            <key>code</key>
            <string>49</string>
        </dict>
        <dict>
            <key>country</key>
            <string>东帝汶</string>
            <key>code</key>
            <string>670</string>
        </dict>
        <dict>
            <key>country</key>
            <string>多哥</string>
            <key>code</key>
            <string>228</string>
        </dict>
        <dict>
            <key>country</key>
            <string>多尼米加共和国</string>
            <key>code</key>
            <string>1809</string>
        </dict>
        <dict>
            <key>country</key>
            <string>多米尼克</string>
            <key>code</key>
            <string>1767</string>
        </dict>
    </array>
    <key>E</key>
    <array>
        <dict>
            <key>country</key>
            <string>厄瓜多尔</string>
            <key>code</key>
            <string>593</string>
        </dict>
        <dict>
            <key>country</key>
            <string>厄立特里亚</string>
            <key>code</key>
            <string>291</string>
        </dict>
        <dict>
            <key>country</key>
            <string>俄罗斯</string>
            <key>code</key>
            <string>7</string>
        </dict>
    </array>
    <key>F</key>
    <array>
        <dict>
            <key>country</key>
            <string>法国</string>
            <key>code</key>
            <string>33</string>
        </dict>
        <dict>
            <key>country</key>
            <string>法罗群岛</string>
            <key>code</key>
            <string>298</string>
        </dict>
        <dict>
            <key>country</key>
            <string>梵蒂冈</string>
            <key>code</key>
            <string>379</string>
        </dict>
        <dict>
            <key>country</key>
            <string>法属波利尼西亚</string>
            <key>code</key>
            <string>689</string>
        </dict>
        <dict>
            <key>country</key>
            <string>法属圣马丁</string>
            <key>code</key>
            <string>1599</string>
        </dict>
        <dict>
            <key>country</key>
            <string>斐济</string>
            <key>code</key>
            <string>679</string>
        </dict>
        <dict>
            <key>country</key>
            <string>菲律宾</string>
            <key>code</key>
            <string>63</string>
        </dict>
        <dict>
            <key>country</key>
            <string>芬兰</string>
            <key>code</key>
            <string>358</string>
        </dict>
        <dict>
            <key>country</key>
            <string>佛得角</string>
            <key>code</key>
            <string>238</string>
        </dict>
        <dict>
            <key>country</key>
            <string>福克兰群岛</string>
            <key>code</key>
            <string>500</string>
        </dict>
    </array>
    <key>G</key>
    <array>
        <dict>
            <key>country</key>
            <string>冈比亚</string>
            <key>code</key>
            <string>220</string>
        </dict>
        <dict>
            <key>country</key>
            <string>刚果(布)</string>
            <key>code</key>
            <string>242</string>
        </dict>
        <dict>
            <key>country</key>
            <string>刚果(金)</string>
            <key>code</key>
            <string>243</string>
        </dict>
        <dict>
            <key>country</key>
            <string>格陵兰</string>
            <key>code</key>
            <string>299</string>
        </dict>
        <dict>
            <key>country</key>
            <string>格林纳达</string>
            <key>code</key>
            <string>1473</string>
        </dict>
        <dict>
            <key>country</key>
            <string>格鲁吉亚</string>
            <key>code</key>
            <string>995</string>
        </dict>
        <dict>
            <key>country</key>
            <string>哥伦比亚</string>
            <key>code</key>
            <string>57</string>
        </dict>
        <dict>
            <key>country</key>
            <string>哥斯达黎加</string>
            <key>code</key>
            <string>506</string>
        </dict>
        <dict>
            <key>country</key>
            <string>关岛</string>
            <key>code</key>
            <string>1671</string>
        </dict>
        <dict>
            <key>country</key>
            <string>古巴</string>
            <key>code</key>
            <string>53</string>
        </dict>
        <dict>
            <key>country</key>
            <string>圭亚那</string>
            <key>code</key>
            <string>592</string>
        </dict>
    </array>
    <key>H</key>
    <array>
        <dict>
            <key>country</key>
            <string>海地</string>
            <key>code</key>
            <string>509</string>
        </dict>
        <dict>
            <key>country</key>
            <string>韩国</string>
            <key>code</key>
            <string>82</string>
        </dict>
        <dict>
            <key>country</key>
            <string>哈萨克斯坦</string>
            <key>code</key>
            <string>7</string>
        </dict>
        <dict>
            <key>country</key>
            <string>黑山</string>
            <key>code</key>
            <string>382</string>
        </dict>
        <dict>
            <key>country</key>
            <string>荷兰</string>
            <key>code</key>
            <string>31</string>
        </dict>
        <dict>
            <key>country</key>
            <string>荷属安地列斯群岛</string>
            <key>code</key>
            <string>599</string>
        </dict>
        <dict>
            <key>country</key>
            <string>洪都拉斯</string>
            <key>code</key>
            <string>504</string>
        </dict>
    </array>
    <key>J</key>
    <array>
        <dict>
            <key>country</key>
            <string>加纳</string>
            <key>code</key>
            <string>233</string>
        </dict>
        <dict>
            <key>country</key>
            <string>加拿大</string>
            <key>code</key>
            <string>1</string>
        </dict>
        <dict>
            <key>country</key>
            <string>柬埔寨</string>
            <key>code</key>
            <string>855</string>
        </dict>
        <dict>
            <key>country</key>
            <string>加蓬</string>
            <key>code</key>
            <string>241</string>
        </dict>
        <dict>
            <key>country</key>
            <string>吉布提</string>
            <key>code</key>
            <string>253</string>
        </dict>
        <dict>
            <key>country</key>
            <string>捷克共和国</string>
            <key>code</key>
            <string>420</string>
        </dict>
        <dict>
            <key>country</key>
            <string>吉尔吉斯斯坦</string>
            <key>code</key>
            <string>996</string>
        </dict>
        <dict>
            <key>country</key>
            <string>基里巴斯</string>
            <key>code</key>
            <string>686</string>
        </dict>
        <dict>
            <key>country</key>
            <string>津巴布韦</string>
            <key>code</key>
            <string>263</string>
        </dict>
        <dict>
            <key>country</key>
            <string>几内亚</string>
            <key>code</key>
            <string>224</string>
        </dict>
        <dict>
            <key>country</key>
            <string>几内亚比绍</string>
            <key>code</key>
            <string>245</string>
        </dict>
    </array>
    <key>K</key>
    <array>
        <dict>
            <key>country</key>
            <string>开曼群岛</string>
            <key>code</key>
            <string>1345</string>
        </dict>
        <dict>
            <key>country</key>
            <string>喀麦隆</string>
            <key>code</key>
            <string>237</string>
        </dict>
        <dict>
            <key>country</key>
            <string>卡塔尔</string>
            <key>code</key>
            <string>974</string>
        </dict>
        <dict>
            <key>country</key>
            <string>科科斯(基林)群岛</string>
            <key>code</key>
            <string>61</string>
        </dict>
        <dict>
            <key>country</key>
            <string>克罗地亚</string>
            <key>code</key>
            <string>385</string>
        </dict>
        <dict>
            <key>country</key>
            <string>科摩罗</string>
            <key>code</key>
            <string>269</string>
        </dict>
        <dict>
            <key>country</key>
            <string>肯尼亚</string>
            <key>code</key>
            <string>254</string>
        </dict>
        <dict>
            <key>country</key>
            <string>科特迪瓦</string>
            <key>code</key>
            <string>225</string>
        </dict>
        <dict>
            <key>country</key>
            <string>科威特</string>
            <key>code</key>
            <string>965</string>
        </dict>
        <dict>
            <key>country</key>
            <string>库克群岛</string>
            <key>code</key>
            <string>682</string>
        </dict>
    </array>
    <key>L</key>
    <array>
        <dict>
            <key>country</key>
            <string>莱索托</string>
            <key>code</key>
            <string>266</string>
        </dict>
        <dict>
            <key>country</key>
            <string>老挝</string>
            <key>code</key>
            <string>856</string>
        </dict>
        <dict>
            <key>country</key>
            <string>拉脱维亚</string>
            <key>code</key>
            <string>371</string>
        </dict>
        <dict>
            <key>country</key>
            <string>黎巴嫩</string>
            <key>code</key>
            <string>961</string>
        </dict>
        <dict>
            <key>country</key>
            <string>利比里亚</string>
            <key>code</key>
            <string>231</string>
        </dict>
        <dict>
            <key>country</key>
            <string>利比亚</string>
            <key>code</key>
            <string>218</string>
        </dict>
        <dict>
            <key>country</key>
            <string>列支敦士登</string>
            <key>code</key>
            <string>423</string>
        </dict>
        <dict>
            <key>country</key>
            <string>立陶宛</string>
            <key>code</key>
            <string>370</string>
        </dict>
        <dict>
            <key>country</key>
            <string>罗马尼亚</string>
            <key>code</key>
            <string>40</string>
        </dict>
        <dict>
            <key>country</key>
            <string>卢森堡</string>
            <key>code</key>
            <string>352</string>
        </dict>
        <dict>
            <key>country</key>
            <string>卢旺达</string>
            <key>code</key>
            <string>250</string>
        </dict>
    </array>
    <key>M</key>
    <array>
        <dict>
            <key>country</key>
            <string>马达加斯加</string>
            <key>code</key>
            <string>261</string>
        </dict>
        <dict>
            <key>country</key>
            <string>马尔代夫</string>
            <key>code</key>
            <string>960</string>
        </dict>
        <dict>
            <key>country</key>
            <string>马耳他</string>
            <key>code</key>
            <string>356</string>
        </dict>
        <dict>
            <key>country</key>
            <string>马来西亚</string>
            <key>code</key>
            <string>60</string>
        </dict>
        <dict>
            <key>country</key>
            <string>马拉维</string>
            <key>code</key>
            <string>265</string>
        </dict>
        <dict>
            <key>country</key>
            <string>马里</string>
            <key>code</key>
            <string>223</string>
        </dict>
        <dict>
            <key>country</key>
            <string>曼岛</string>
            <key>code</key>
            <string>44</string>
        </dict>
        <dict>
            <key>country</key>
            <string>毛里求斯</string>
            <key>code</key>
            <string>230</string>
        </dict>
        <dict>
            <key>country</key>
            <string>毛里塔尼亚</string>
            <key>code</key>
            <string>222</string>
        </dict>
        <dict>
            <key>country</key>
            <string>马其顿</string>
            <key>code</key>
            <string>389</string>
        </dict>
        <dict>
            <key>country</key>
            <string>马绍尔群岛</string>
            <key>code</key>
            <string>692</string>
        </dict>
        <dict>
            <key>country</key>
            <string>马约特</string>
            <key>code</key>
            <string>262</string>
        </dict>
        <dict>
            <key>country</key>
            <string>美国</string>
            <key>code</key>
            <string>1</string>
        </dict>
        <dict>
            <key>country</key>
            <string>美属萨摩亚</string>
            <key>code</key>
            <string>1684</string>
        </dict>
        <dict>
            <key>country</key>
            <string>美属维京群岛</string>
            <key>code</key>
            <string>1340</string>
        </dict>
        <dict>
            <key>country</key>
            <string>蒙古</string>
            <key>code</key>
            <string>976</string>
        </dict>
        <dict>
            <key>country</key>
            <string>孟加拉国</string>
            <key>code</key>
            <string>880</string>
        </dict>
        <dict>
            <key>country</key>
            <string>蒙特塞拉特</string>
            <key>code</key>
            <string>1664</string>
        </dict>
        <dict>
            <key>country</key>
            <string>缅甸</string>
            <key>code</key>
            <string>95</string>
        </dict>
        <dict>
            <key>country</key>
            <string>密克罗尼西亚</string>
            <key>code</key>
            <string>691</string>
        </dict>
        <dict>
            <key>country</key>
            <string>秘鲁</string>
            <key>code</key>
            <string>51</string>
        </dict>
        <dict>
            <key>country</key>
            <string>摩尔多瓦</string>
            <key>code</key>
            <string>373</string>
        </dict>
        <dict>
            <key>country</key>
            <string>摩洛哥</string>
            <key>code</key>
            <string>212</string>
        </dict>
        <dict>
            <key>country</key>
            <string>摩纳哥</string>
            <key>code</key>
            <string>377</string>
        </dict>
        <dict>
            <key>country</key>
            <string>莫桑比克</string>
            <key>code</key>
            <string>258</string>
        </dict>
        <dict>
            <key>country</key>
            <string>墨西哥</string>
            <key>code</key>
            <string>52</string>
        </dict>
    </array>
    <key>N</key>
    <array>
        <dict>
            <key>country</key>
            <string>纳米比亚</string>
            <key>code</key>
            <string>264</string>
        </dict>
        <dict>
            <key>country</key>
            <string>南非</string>
            <key>code</key>
            <string>27</string>
        </dict>
        <dict>
            <key>country</key>
            <string>南极洲</string>
            <key>code</key>
            <string>672</string>
        </dict>
        <dict>
            <key>country</key>
            <string>瑙鲁</string>
            <key>code</key>
            <string>674</string>
        </dict>
        <dict>
            <key>country</key>
            <string>尼泊尔</string>
            <key>code</key>
            <string>977</string>
        </dict>
        <dict>
            <key>country</key>
            <string>尼加拉瓜</string>
            <key>code</key>
            <string>505</string>
        </dict>
        <dict>
            <key>country</key>
            <string>尼日尔</string>
            <key>code</key>
            <string>227</string>
        </dict>
        <dict>
            <key>country</key>
            <string>尼日利亚</string>
            <key>code</key>
            <string>234</string>
        </dict>
        <dict>
            <key>country</key>
            <string>纽埃</string>
            <key>code</key>
            <string>683</string>
        </dict>
        <dict>
            <key>country</key>
            <string>挪威</string>
            <key>code</key>
            <string>47</string>
        </dict>
    </array>
    <key>P</key>
    <array>
        <dict>
            <key>country</key>
            <string>帕劳</string>
            <key>code</key>
            <string>680</string>
        </dict>
        <dict>
            <key>country</key>
            <string>皮特凯恩群岛</string>
            <key>code</key>
            <string>870</string>
        </dict>
        <dict>
            <key>country</key>
            <string>葡萄牙</string>
            <key>code</key>
            <string>351</string>
        </dict>
    </array>
    <key>R</key>
    <array>
        <dict>
            <key>country</key>
            <string>日本</string>
            <key>code</key>
            <string>81</string>
        </dict>
        <dict>
            <key>country</key>
            <string>瑞典</string>
            <key>code</key>
            <string>46</string>
        </dict>
        <dict>
            <key>country</key>
            <string>瑞士</string>
            <key>code</key>
            <string>41</string>
        </dict>
    </array>
    <key>S</key>
    <array>
        <dict>
            <key>country</key>
            <string>萨尔瓦多</string>
            <key>code</key>
            <string>503</string>
        </dict>
        <dict>
            <key>country</key>
            <string>塞尔维亚</string>
            <key>code</key>
            <string>381</string>
        </dict>
        <dict>
            <key>country</key>
            <string>塞拉利昂</string>
            <key>code</key>
            <string>232</string>
        </dict>
        <dict>
            <key>country</key>
            <string>塞内加尔</string>
            <key>code</key>
            <string>221</string>
        </dict>
        <dict>
            <key>country</key>
            <string>塞浦路斯</string>
            <key>code</key>
            <string>357</string>
        </dict>
        <dict>
            <key>country</key>
            <string>塞舌尔</string>
            <key>code</key>
            <string>248</string>
        </dict>
        <dict>
            <key>country</key>
            <string>萨摩亚</string>
            <key>code</key>
            <string>685</string>
        </dict>
        <dict>
            <key>country</key>
            <string>沙特阿拉伯</string>
            <key>code</key>
            <string>966</string>
        </dict>
        <dict>
            <key>country</key>
            <string>圣巴泰勒米</string>
            <key>code</key>
            <string>590</string>
        </dict>
        <dict>
            <key>country</key>
            <string>圣诞岛</string>
            <key>code</key>
            <string>61</string>
        </dict>
        <dict>
            <key>country</key>
            <string>圣多美和普林西比</string>
            <key>code</key>
            <string>239</string>
        </dict>
        <dict>
            <key>country</key>
            <string>圣赫勒拿</string>
            <key>code</key>
            <string>290</string>
        </dict>
        <dict>
            <key>country</key>
            <string>圣基茨和尼维斯</string>
            <key>code</key>
            <string>1869</string>
        </dict>
        <dict>
            <key>country</key>
            <string>圣卢西亚</string>
            <key>code</key>
            <string>1758</string>
        </dict>
        <dict>
            <key>country</key>
            <string>圣马力诺</string>
            <key>code</key>
            <string>378</string>
        </dict>
        <dict>
            <key>country</key>
            <string>圣皮埃尔和密克隆群岛</string>
            <key>code</key>
            <string>508</string>
        </dict>
        <dict>
            <key>country</key>
            <string>圣文森特和格林纳丁斯</string>
            <key>code</key>
            <string>1784</string>
        </dict>
        <dict>
            <key>country</key>
            <string>斯里兰卡</string>
            <key>code</key>
            <string>94</string>
        </dict>
        <dict>
            <key>country</key>
            <string>斯洛伐克</string>
            <key>code</key>
            <string>421</string>
        </dict>
        <dict>
            <key>country</key>
            <string>斯洛文尼亚</string>
            <key>code</key>
            <string>386</string>
        </dict>
        <dict>
            <key>country</key>
            <string>斯威士兰</string>
            <key>code</key>
            <string>268</string>
        </dict>
        <dict>
            <key>country</key>
            <string>苏丹</string>
            <key>code</key>
            <string>249</string>
        </dict>
        <dict>
            <key>country</key>
            <string>苏里南</string>
            <key>code</key>
            <string>597</string>
        </dict>
        <dict>
            <key>country</key>
            <string>所罗门群岛</string>
            <key>code</key>
            <string>677</string>
        </dict>
        <dict>
            <key>country</key>
            <string>索马里</string>
            <key>code</key>
            <string>252</string>
        </dict>
    </array>
    <key>T</key>
    <array>
        <dict>
            <key>country</key>
            <string>泰国</string>
            <key>code</key>
            <string>66</string>
        </dict>
        <dict>
            <key>country</key>
            <string>台湾</string>
            <key>code</key>
            <string>886</string>
        </dict>
        <dict>
            <key>country</key>
            <string>塔吉克斯坦</string>
            <key>code</key>
            <string>992</string>
        </dict>
        <dict>
            <key>country</key>
            <string>汤加</string>
            <key>code</key>
            <string>676</string>
        </dict>
        <dict>
            <key>country</key>
            <string>坦桑尼亚</string>
            <key>code</key>
            <string>255</string>
        </dict>
        <dict>
            <key>country</key>
            <string>特克斯和凯科斯群岛</string>
            <key>code</key>
            <string>1649</string>
        </dict>
        <dict>
            <key>country</key>
            <string>特立尼达和多巴哥</string>
            <key>code</key>
            <string>1868</string>
        </dict>
        <dict>
            <key>country</key>
            <string>土耳其</string>
            <key>code</key>
            <string>90</string>
        </dict>
        <dict>
            <key>country</key>
            <string>土库曼斯坦</string>
            <key>code</key>
            <string>993</string>
        </dict>
        <dict>
            <key>country</key>
            <string>突尼斯</string>
            <key>code</key>
            <string>216</string>
        </dict>
        <dict>
            <key>country</key>
            <string>托克劳</string>
            <key>code</key>
            <string>690</string>
        </dict>
        <dict>
            <key>country</key>
            <string>图瓦卢</string>
            <key>code</key>
            <string>688</string>
        </dict>
    </array>
    <key>W</key>
    <array>
        <dict>
            <key>country</key>
            <string>瓦利斯和富图纳</string>
            <key>code</key>
            <string>681</string>
        </dict>
        <dict>
            <key>country</key>
            <string>瓦努阿图</string>
            <key>code</key>
            <string>678</string>
        </dict>
        <dict>
            <key>country</key>
            <string>危地马拉</string>
            <key>code</key>
            <string>502</string>
        </dict>
        <dict>
            <key>country</key>
            <string>委内瑞拉</string>
            <key>code</key>
            <string>58</string>
        </dict>
        <dict>
            <key>country</key>
            <string>文莱</string>
            <key>code</key>
            <string>673</string>
        </dict>
        <dict>
            <key>country</key>
            <string>乌干达</string>
            <key>code</key>
            <string>256</string>
        </dict>
        <dict>
            <key>country</key>
            <string>乌克兰</string>
            <key>code</key>
            <string>380</string>
        </dict>
        <dict>
            <key>country</key>
            <string>乌拉圭</string>
            <key>code</key>
            <string>598</string>
        </dict>
        <dict>
            <key>country</key>
            <string>乌兹别克斯坦</string>
            <key>code</key>
            <string>998</string>
        </dict>
    </array>
    <key>X</key>
    <array>
        <dict>
            <key>country</key>
            <string>西班牙</string>
            <key>code</key>
            <string>34</string>
        </dict>
        <dict>
            <key>country</key>
            <string>希腊</string>
            <key>code</key>
            <string>30</string>
        </dict>
        <dict>
            <key>country</key>
            <string>新加坡</string>
            <key>code</key>
            <string>65</string>
        </dict>
        <dict>
            <key>country</key>
            <string>新喀里多尼亚</string>
            <key>code</key>
            <string>687</string>
        </dict>
        <dict>
            <key>country</key>
            <string>新西兰</string>
            <key>code</key>
            <string>64</string>
        </dict>
        <dict>
            <key>country</key>
            <string>匈牙利</string>
            <key>code</key>
            <string>36</string>
        </dict>
        <dict>
            <key>country</key>
            <string>叙利亚</string>
            <key>code</key>
            <string>963</string>
        </dict>
    </array>
    <key>Y</key>
    <array>
        <dict>
            <key>country</key>
            <string>牙买加</string>
            <key>code</key>
            <string>1876</string>
        </dict>
        <dict>
            <key>country</key>
            <string>亚美尼亚</string>
            <key>code</key>
            <string>374</string>
        </dict>
        <dict>
            <key>country</key>
            <string>也门</string>
            <key>code</key>
            <string>967</string>
        </dict>
        <dict>
            <key>country</key>
            <string>意大利</string>
            <key>code</key>
            <string>39</string>
        </dict>
        <dict>
            <key>country</key>
            <string>伊拉克</string>
            <key>code</key>
            <string>964</string>
        </dict>
        <dict>
            <key>country</key>
            <string>伊朗</string>
            <key>code</key>
            <string>98</string>
        </dict>
        <dict>
            <key>country</key>
            <string>印度</string>
            <key>code</key>
            <string>91</string>
        </dict>
        <dict>
            <key>country</key>
            <string>印度尼西亚</string>
            <key>code</key>
            <string>62</string>
        </dict>
        <dict>
            <key>country</key>
            <string>英国</string>
            <key>code</key>
            <string>44</string>
        </dict>
        <dict>
            <key>country</key>
            <string>英属维京群岛</string>
            <key>code</key>
            <string>1284</string>
        </dict>
        <dict>
            <key>country</key>
            <string>以色列</string>
            <key>code</key>
            <string>972</string>
        </dict>
        <dict>
            <key>country</key>
            <string>约旦</string>
            <key>code</key>
            <string>962</string>
        </dict>
        <dict>
            <key>country</key>
            <string>越南</string>
            <key>code</key>
            <string>84</string>
        </dict>
    </array>
    <key>Z</key>
    <array>
        <dict>
            <key>country</key>
            <string>赞比亚</string>
            <key>code</key>
            <string>260</string>
        </dict>
        <dict>
            <key>country</key>
            <string>乍得</string>
            <key>code</key>
            <string>235</string>
        </dict>
        <dict>
            <key>country</key>
            <string>直布罗陀</string>
            <key>code</key>
            <string>350</string>
        </dict>
        <dict>
            <key>country</key>
            <string>智利</string>
            <key>code</key>
            <string>56</string>
        </dict>
        <dict>
            <key>country</key>
            <string>中非共和国</string>
            <key>code</key>
            <string>236</string>
        </dict>
        <dict>
            <key>country</key>
            <string>中国</string>
            <key>code</key>
            <string>86</string>
        </dict>
        <dict>
            <key>country</key>
            <string>中国澳门特别行政区</string>
            <key>code</key>
            <string>853</string>
        </dict>
        <dict>
            <key>country</key>
            <string>中国香港特别行政区</string>
            <key>code</key>
            <string>852</string>
        </dict>
    </array>
</dict>
</plist>

相关文章

网友评论

      本文标题:Swift-国家选择区号列表

      本文链接:https://www.haomeiwen.com/subject/cxqeuxtx.html