gpt4 book ai didi

ios - 如何在 Swift iOS 中通过 Pincode 获取城市、州和国家名称?

转载 作者:可可西里 更新时间:2023-11-01 00:21:30 25 4
gpt4 key购买 nike

<分区>

我有五个文本字段,我想在输入密码时自动填充区域、城市、州和国家/地区。

 import UIKit
import CoreLocation

class CreateGroupView: UIViewController,UITextFieldDelegate,CLLocationManagerDelegate
{
//View Did Load
override func viewDidLoad() {
super.viewDidLoad()

let location: String = "305621"//"yourPINCode"
let geocoder: CLGeocoder = CLGeocoder()
geocoder.geocodeAddressString(location,completionHandler: {(placemarks: [CLPlacemark]?, error: NSError?) -> Void in
if ((placemarks?.count)! > 0) {
let placemark: CLPlacemark = (placemarks?[0])!
let country : String = placemark.country!
let state: String = placemark.administrativeArea!
print(country)
print(state)
}
} as! CLGeocodeCompletionHandler)
}
}

我该怎么做?谢谢

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com