0

I have a Table View with four Prototype Cells, each one of them has an Identifier, but in code, I want to get the value of the identifier to make decisions.

I would like to assign it to a variable, and then, use the switch statement or If..Then..

Xcode 7.3/Swift 2.2

Thanks!

arthurbas
  • 29
  • 1
  • 7
  • You need to make the decisions base on your models data. – José Roberto Abreu Jul 12 '16 at 03:24
  • Thanks Jose for your comment, but I am building a product catalog and I am not using models data. I want to act based on the cell identifier because this value won't change. – arthurbas Jul 12 '16 at 21:15
  • I was trying to explain you, that base on your data (Ex. the products that your going to show or what else), you're going to use the identifier (that you know before hand), because the datasource (UITableViewDataSource) don't give to you the identifier (that's something that you need to do). – José Roberto Abreu Jul 13 '16 at 14:11
  • Base on the answer of Aravi. I think that I don't understand your question, do you want to show different prototype cell base on some condition or do something when you select a cell? – José Roberto Abreu Jul 13 '16 at 14:13

1 Answers1

0

use delegate method didSelectRowAtIndexPath

Aravind
  • 1,040
  • 1
  • 12
  • 17
  • I have been searching how to implement the delegate method. Can you show me a website where I can see it, or if you have a small sample I can follow will be really appreciated. Sorry I forgot to mention that I am a beginner. Thanks! – arthurbas Jul 12 '16 at 21:45
  • check this link --> http://stackoverflow.com/questions/33234180/uitableview-example-for-swift – Aravind Jul 13 '16 at 09:00
  • appcoda and raywenderlich websites are very useful. You can get more examples – Aravind Jul 13 '16 at 09:07
  • Thanks for the information provided, I have been getting better since I've been doing this for some weeks now, I've been practicing a lot and I have made like seven projects with tableViews, but this project in particular which I am doing on my own is different. But now I am moving to a different approach, and using tableviews with sections, and I have made one or two samples so far. – arthurbas Jul 17 '16 at 04:07