0

Sorry but I really new in this case.

I have a project where I use revealViewController. And inside this project I have UITableView with 4 prototype cells within where each cell shows the user another UIView by segue. Every cell has its own identifier, for example: cell1, cell2, cell3, cell4.

In code I implement an array that must contain the same strings of names of the cells to work properly:

array = ["cell1", "cell2", "cell3", "cell4"]

And everything is working fine, in first row of the UITableView I see "cell1", on second row - "cell2" and etc.

But now I want to localize my app and I want to change names of these 4 rows according to the language of the user/application. The problem is that names must be equals to cell identifier. So no if I change a name neither I change an identifier separately I've got SIGART error.

So, my question is what should I do? Should I change cell identifier in code due NSLocalizedString? Or there is another solution? Thank to everyone in advance.

ZhangChn
  • 3,154
  • 21
  • 41
  • 1
    I think you're missing the purpose of a cell identifier. The identifier is so the dequeing process can properly identify what type of cell you want to use. In other words, if you have 3 different "types" of cells, they'll have 3 identifiers. If your cells are exactly the same just use one identifier. – Dan Beaulieu Dec 22 '15 at 14:40
  • Make a custom subclass of `UITableViewCell`: you could add the properties you need to keep reference as well as text (e.g. a `UILabel` in your custom cell class) or other objects in your custom cells. – dfrib Dec 22 '15 at 14:40
  • Thank you for advise. I use that code dequeuing my 4 cells: let cell = tableView.dequeueReusableCellWithIdentifier(TableArray[indexPath.row], forIndexPath: indexPath) as UITableViewCell where TableArray is like the array I wrote above. And it works fine till I want to localise the names – Nikita Ostrovsky Dec 22 '15 at 14:55
  • I would avoid making an implementation detail, such as reuseIdentifiers, visible to the user. You should update your logic to use a fixed reuseIdentifier and then get a localized string for display from another source. – Stephen Dec 22 '15 at 17:14
  • Thank's to everyone guys! I found a way to my solution in that post: http://stackoverflow.com/questions/30774671/uitableview-with-more-than-one-custom-cells-with-swift. Now it works fine for me)))) – Nikita Ostrovsky Dec 22 '15 at 20:33

0 Answers0