I'd like to be able to use the same layout and viewcontroller but use different data set in different parts of the app. Is this possible without having to create another separate viewcontroller?
Because in my viewDid load I'm already calling upon an API request for that specific viewcontroller... Would there be a way to distinctly set a switch case on which viewcontroller it is supposed to be on?
I'm using storyboard and the stack hierarchy in navigation controller and looks similar to this:
V1 --> V2 --> V3 --> V4
So the idea is... same layout with different data. V1 and V4 should have the same exact layout. But the data set would be just a bit different. V1 is set up correctly and working fine already.
Is this a segue issue? Or something else? Thanks !! Much appreicated!!
Please don't create 2 UIViewControllers that are almost exactly the same.
There are several ways to solve your problem. But since you're using Storyboards and segues, we'll do it that way.
In your V1 controller create a method to pass in the type of data that should be loaded. Something like this:
Objective-C
In your V1 you'll have to move the logic that makes the API call from viewDidLoad into that new method. Something like:
Now in V3 in
prepareForSegue
method do this:Swift 3
In V3
prepareForSegue