I'm using storyboards, and I have two controllers. One writes data, the other reads data.
I'm not sure how to get my data form one page to the other. After some testing I see I can pass data using:
"relet" being my class.
I can see context on my other controller here:
I can see context has data... but how am I able to map it to relet = context???
I don't see how to get the data back... I can seem to send it, but getting it is becoming a struggle, and the struggle is real O.o
I'm not sure how to get my data form one page to the other. After some testing I see I can pass data using:
Code Block language override func contextForSegue(withIdentifier segueIdentifier: String) -> Any?{ return self.relet }
"relet" being my class.
I can see context on my other controller here:
Code Block language override func awake(withContext context: Any?){ print("awake") }
I can see context has data... but how am I able to map it to relet = context???
I don't see how to get the data back... I can seem to send it, but getting it is becoming a struggle, and the struggle is real O.o
Ok I think I figured out what to do. I'll document it for anyone who is interested.
On controller1 you pass the data with
Then on your second controller you do this
Now you'll be able to use the data however you like.
Here are some good references:
Stackoverflow
Apple Documentation
On controller1 you pass the data with
Code Block language var relet = ReletClass (my Class) override func contextForSegue(withIdentifier segueIdentifier: String) -> Any?{ return self.relet <--- (or whatever your class is) }
Then on your second controller you do this
Code Block language var relet = ReletClass () override func awake(withContext context: Any?){ if let myClass = context as? ReletClass{ relet = myClass (this loads the data passed to your second controller into your var) } }
Now you'll be able to use the data however you like.
Here are some good references:
Stackoverflow
Apple Documentation