Skip to content

Instantly share code, notes, and snippets.

@hachinobu
Created August 9, 2015 13:31
Show Gist options
  • Save hachinobu/6d7b1ad92efe8a13164b to your computer and use it in GitHub Desktop.
Save hachinobu/6d7b1ad92efe8a13164b to your computer and use it in GitHub Desktop.
TableViewのsectionとrowの情報をEnumを利用して定義してみる
struct TableSectionRowInfo {
enum RowInfo {
case SecOne1
case SecOne2
case SecTwo1
case SecTwo2
case SecTwo3
func rowCount() -> Int {
switch(self) {
case .SecOne1:
return 1
case .SecOne2:
return 2
case .SecTwo1:
return 3
case .SecTwo2:
return 4
case .SecTwo3:
return 5
}
}
}
enum SectionInfo {
case SecOne(RowInfo)
case SecTwo(RowInfo)
func rowCount() -> Int {
switch(self) {
case .SecOne(let row):
return row.rowCount()
case .SecTwo(let row):
return row.rowCount()
}
}
}
var sectionInfo: SectionInfo
func row() -> Int {
return sectionInfo.rowCount()
}
}
let tableinfo = TableSectionRowInfo(sectionInfo: .SecOne(.SecOne1))
tableinfo.row()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment