Search code examples
xcodecore-dataswift3segue

Swift 3 - storyboard design for table VC (using of coredata) and details VC *starting in detail VC with default info*


I am building my first app. I have a table VC with a number of items. Clicking an item leads to details VC with this item info (uses coredata).

The question is - what storyboard design should I use (VC types and segue/s). If I want the app to start in the details VC with a new info fetched from a url (not with coredata) and show it and allow the user to move to the table VC to pick the core data fetched item.


Solution

  • You could use manual segues, which give you the most control of when to initiate the segue and which view controller to start as the first in your app (unlike NavigationController which forces you to make the first view the one at the top of your navigation stack - i.e., in your case that would be your TableViewController).

    Manual segues can be created by going to the Storyboard view and, in the Document Outline sidebar on the left(which may need to be expanded to see), Ctrl+clicking the starting ViewController and dragging the line that appears to the destination ViewController (first image below). Then select "show" from the menu that appears (second image below). Then name the segue in the identity tab of the Utilities sidebar on the right (also may need to be expanded to see) (third image below). Then initiate that segue in the starting ViewController class whenever you choose using the following, assuming the name of your segue is "showDestViewControllerSegue":

    self.performSegue(withIdentifier: "showDestViewControllerSegue", sender:nil)
    

    enter image description here

    enter image description here

    enter image description here