Oss written in swift
- 2. ?浅井勇樹 28歳
?Github : yukiasai
?出身:福井県 福井高専
?今 : 株式会社マネーフォワード
?マネーフォワード - 自動家計簿アプリ
?過去 : 株式会社ナチュラルスタイル
?ZOZOTOWN - ファッション通販アプリ
?WEAR - ファッションコーディネートアプリ
?得意 : iOS
?趣味 : ディズニーランド
自己紹介
- 12. UITableViewを普通に使うとこうなる
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 3
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch section {
case 0: return 5
case 1: return 3
default: fatalError()
}
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) ->
UITableViewCell {
switch (indexPath.section, indexPath.row) {
case (0, _):
let cell = tableView.dequeueReusableCellWithIdentifier("MemberCell") as! MemberTableViewCell
return cell
case (1, _):
let cell = tableView.dequeueReusableCellWithIdentifier("GroupCell") as! GroupTableViewCell
return cell
default:
fatalError()
}
}
- 14. Shoyuだとこうなる
tableView.source = Source()
.createSection { section in
section.createRows(5) { (_, row: Row<MemberTableViewCell>) in
row.height = 52
row.configureCell = { cell, _ in }
row.didSelect = { _ in }
}
}
.createSection { section in
section.createRows(3) { (_, row: Row<GroupTableViewCell>) in
row.height = 52
row.configureCell = { cell, _ in }
row.didSelect = { _ in }
}
}
tableView.reloadData()
- 19. Kaisekiを使うとこうなる
こんなオブジェクトを宣言
class Object: Entity {
// Basic
let int = Property<Int>()
let string = Property<String>()
// Array
let array = Property<[Bool]>()
// Optional
let optional = Property<Int?>()
// Entity
let object = Property<Object?>()
}
使い方
let json: [String: AnyObject] = [“int”: 1, “string”: “aaa”, “array”: [true, false], “optional”: null, ....]
let obj = Object.fromJSON(json: jsonData)
obj.int.value // -> 1
obj.string.value // -> aaa