I would like to cancel an unwind segue if the textbox values are equal to nil. below is the current code. I used storyboard to connect the save button (saves values of text into database). I was thinking about using poptorootviewcontroller to ensure the textbook has values before performing segue. is their any way to do this with current code?
code inside of mainView to unwind back to-
@IBAction func unwind(_ segue: UIStoryboardSegue){
print("Back in TableView")
}
button on childView perform unwind segue-
@IBAction func saveAddress(_ sender: UIButton) {
// save values to dictionary save dictionary to firebase under user, uid, addresses
// uialert controller if fields are not completed do not allow segue if fields are not complete
// perform segue to addresstableview
let addy1: String = address1Txt.text!
let addy2: String = address2Txt.text!
let aptNum: String = aptTxt.text!
let city: String = cityTxt.text!
let state: String = stateTxt.text!
let zip: String = zipTxt.text!
// add UIAlert controller for address field == nothing
if addy1.isEmpty && aptNum.isEmpty && city.isEmpty && state.isEmpty && zip.isEmpty
{
//add UIAlert Controller DO NOT PERFORM SEGUE IF TRUE
}
Address.sharedInsance.typedNewAddress = addy1 + "," + addy2 + "," + aptNum + "," + city + "," + state + "," + zip
print("address save print",addy1, addy2, aptNum, city, state, zip)
let key = ref.child("address").childByAutoId().key
let setter = false
let addyDict = ["address line 1":addy1,"address line 2":addy2,"apt Number":aptNum,"city":city,"state":state,"zip":zip,"keyID": key, "setter": setter] as [String : Any]
let userID = Auth.auth().currentUser?.uid
let childUpdates = ["/address/\(key)": addyDict]
ref.child("users").child(userID!).updateChildValues(childUpdates)
}