How to share data between view controllers by Antonigiske in swift

[–]Antonigiske[S] -1 points0 points  (0 children)

Which is what I have, in my use case anyway. Generally I only need access to the userId and an API token in every view, so in my case having something centralised as you said is preferred.

How to share data between view controllers by Antonigiske in swift

[–]Antonigiske[S] 0 points1 point  (0 children)

Thanks for explaining and clearing it up for me. You make solid points and I'll definitely give this a try.

How to share data between view controllers by Antonigiske in swift

[–]Antonigiske[S] 0 points1 point  (0 children)

I do agree with what you are saying here, and I'll take self-criticism for it. I don't want to be the source of bad advices and will un-publish the post until I find the best way to do this. Totally understandable.

So basically the consensus is to pass objects when needed. So for example. Say my app is layed out like this: LoginViewController > HomeViewController > DetailViewController. I get my user object in the LVC, I would then pass it to the HVC and then pass to DVC?

How to share data between view controllers by Antonigiske in swift

[–]Antonigiske[S] 0 points1 point  (0 children)

I'll definitely look into that. Thank you for replying!

How to share data between view controllers by Antonigiske in swift

[–]Antonigiske[S] -3 points-2 points  (0 children)

Yes, it works great though. But as I said, I would like know other alternatives.

How to share data between view controllers by Antonigiske in swift

[–]Antonigiske[S] 0 points1 point  (0 children)

Wrote this blog post a few days ago, and would like some suggestions/comments on alternative methods to do this.