Friday, November 6, 2026
HomeiOS Developmentios - Save configuration from class to class via save Button in...

ios – Save configuration from class to class via save Button in a selected VC

[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

So the default have to be the URL that you’re seeing however If the person resolve to vary that and press the button “Ruaj” then the URL must be up to date within the APICaller class to, Unwell present how the code is structured within the APICaller class the place the URL must be up to date

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]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments