Лучшие практики по реализации идентификатора для модели представления представления типа списка [закрыто]IOS

Программируем под IOS
Ответить Пред. темаСлед. тема
Anonymous
 Лучшие практики по реализации идентификатора для модели представления представления типа списка [закрыто]

Сообщение Anonymous »


I am implementing a view model for a stacks of customized UIView. we're giving an id parameter to the view modal. so when user tap on the view. a delegate method is triggered and one of parameters that we pass through the method is the "id" in the view model. so the client knows which view is tapped and react accordingly.

Currently we are using an Int type for the id. But we want to refactor it to adapt to best practise. so there is a comment in the code saying we should use "enum case of type 'Any' instead of an Int type" I'm not sure what does it mean. so I was thinking may be they want to use 'Any' as the type of id? so when client customize the id to use either Enum or Int? does anyone can help me to figure out what does the comment mean? or provide a better implementation for this id? Thanks in advance. the following is the current version.

public struct ViewModel { let id: Int let text: String let isSelected: Bool public init(id: Int, text: String, isSelected: Bool) { self.id = id self.text = text self.isSelected = isSelected } }


Источник: https://stackoverflow.com/questions/780 ... -type-view
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «IOS»