Conditional segues for specific row in tableview: Swift

Discussion in 'Mac Programming' started by jonpeter, Feb 11, 2015.

  1. jonpeter macrumors member

    Joined:
    Sep 19, 2013
    Location:
    MI
    #1
    Let give you an example to help clarify my question.
    So I have a list of different types of restaurants: American, Chinese, Indian, etc set up in a table view.
    I looking to, that upon selection of one of these types of restaurants, it brings you to a list of restaurants associated with that type of food.
    So if a user clicked on American- you would be presented with a list of american restaurants such as Big Boy, McDonalds, etc.

    I understand how to create the table view and list associated with the table, but I am unsure how to go about creating conditional segues for each cell/row. Do you have any ideas/suggestions I should look into? A code example would be extremely helpful as well.

    I believe the action requires setting up an index path.row for each type of restaurant type, but I am unsure how to go about it.

    Any help would be appreciated. thanks!
     
  2. jonpeter thread starter macrumors member

    Joined:
    Sep 19, 2013
    Location:
    MI
    #2
    so after playing around with my code, I was able to achieve what i was asking.

    however, is their a more "name friendly" way to get my conditional segue started? For example,

    in the did select row function, instead of specifying "if index path.row == 0 ... perform with segue one", would i be able to set the index path.row to a name in my array? Or can the connection only be made between "index path" and the # in the array?
     

Share This Page