I have been able to pass data from one view to the next.
Now I need to expand a bit and pass this data via three view controllers.
I have three view controllers 1.MileageControler, 2.LocationsControler and 3.LocationChoiceController.
I need to be able to pass data from 1 to 2 then onto 3 and then back to 2.
Mileage Controler has a textbox and a series of numeric buttons that allow the user to enter a mileage. An Enter button passed the following on seque
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
if (segue.identifier == "segueLocationView") {
let passingData = segue.destinationViewController as! LocationViewController;
passingData.mileageToPass = DisplayStart.text
passingData.fuelAmountToPass = 0.00
passingData.startLocationToPass = "HOME"
passingData.endLocationToPass = ""
}
}
The LocationController has:
var mileageToPass: String!
var fuelAmountToPass: Double!
var startLocationToPass: String!
var endLocationToPass: String!
override func viewDidLoad() {
super.viewDidLoad()
labelStartMileage.text = "Start Mileage for this trip: " + mileageToPass
labelStartLocation.text = startLocationToPass
labelEndLocation.text = endLocationToPass
}
It also has...
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
if (segue.identifier == "segueChoiceMade") {
let passingData = segue.destinationViewController as! LocationChoiceViewController;
passingData.mileageToPass = mileageToPass
passingData.fuelAmountToPass = fuelAmountToPass
passingData.startLocationToPass = labelStart.text
passingData.endLocationToPass = txtEndLocation.text
if (sender === but_StartLocation) {
passingData.senderToPass = "Start"
} else if (sender === but_Destination) {
passingData.senderToPass = "End"
}
}
}
So here I'm trying to pass the data on again to the next view (LocationChoice) where the user will choose a location and based on which senderToPass value was passed then the chosen location will be stored and passed back in either startLocationToPass or endLocationToPass. The mileageToPass and fuelAmmountToPass are not changed in LocationChoice just stored and passed back.
The problem I'm having are errors which just show up as... Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) Am I going about this the wrong way....