[ad_1]
I’ve a View Controller which has a UITextField and a button under it which i wish to configure it when its pressed to avoid wasting the information that are within the UITextField and retailer that knowledge to the API class, Unwell present among the code and pictures under
The code for the Settings class:
@IBOutlet weak var apiTextField: UITextField!
@IBOutlet weak var saveButton: UIButton!
@IBAction func theSaveButton(_ sender: Any) {
let alert = UIAlertController(title: "", message: "The configurations are being saved...", preferredStyle: .alert)
self.current(alert, animated: true, completion: nil)
Timer.scheduledTimer(withTimeInterval: 3, repeats: false) { _ in
guard let tabBarController = self.storyboard?.instantiateViewController(withIdentifier: "qrCode") else {
return
}
tabBarController.modalPresentationStyle = .customized
self.current(tabBarController, animated: true, completion: nil)
}
}
The APICaller class:
class APICaller {
let token = "NjQzODM2N0NDNDM4GSH350NjA03536GSE3E="
static let shared = APICaller()
var baseURL = "http://411.42.111.234:3050/api/" // the URL when save Button is pressed must replace the baseURL right here :)
func getVehicles(for id: String, accomplished: @escaping (End result<[Vehicles],OnTraErrors>) -> Void ){
let endpoint = baseURL + "GetVehicles/?UserIdentificationValue=(id)"
I consider this is perhaps very simple however for me as a brand new Swift wanabe Dev I’m having difficulties like everybody who began out this journey however I’m really studying on each day foundation via this wonderful neighborhood!
[ad_2]
