質問編集履歴
2
ソースコードの追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
### 該当のソースコード
|
21
21
|
|
22
|
-
```
|
22
|
+
```tableviewController
|
23
23
|
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
24
24
|
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! TimeLineCell
|
25
25
|
cell.timeLineModel = self.timeLines[indexPath.row]
|
@@ -47,9 +47,45 @@
|
|
47
47
|
detailViewController.groupName = groupName
|
48
48
|
detailViewController.constitution = constitution
|
49
49
|
}
|
50
|
+
```
|
51
|
+
```TimeLineModel
|
52
|
+
import Foundation
|
53
|
+
import Firebase
|
50
54
|
|
55
|
+
class TimeLineModel {
|
56
|
+
|
57
|
+
var musicName:String = ""
|
58
|
+
var groupName:String = ""
|
59
|
+
var constitution:String = ""
|
60
|
+
var ref = Firestore.firestore().collection("timeLine")
|
61
|
+
|
62
|
+
|
63
|
+
init(musicName:String,groupName:String,constitution:String) {
|
64
|
+
|
65
|
+
self.musicName = musicName
|
66
|
+
self.groupName = groupName
|
67
|
+
self.constitution = constitution
|
68
|
+
}
|
69
|
+
|
70
|
+
init(document:QueryDocumentSnapshot) {
|
71
|
+
|
72
|
+
if let value = document.data() as? [String:Any] {
|
73
|
+
|
74
|
+
musicName = value["musicName"] as! String
|
75
|
+
groupName = value["groupName"] as! String
|
76
|
+
constitution = value["constitution"] as! String
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
func toContents() -> [String:Any] {
|
81
|
+
return ["musicName":musicName,"groupName":groupName,"constitution":constitution]
|
82
|
+
}
|
83
|
+
|
84
|
+
func save() {
|
85
|
+
ref.addDocument(data: toContents())
|
86
|
+
}
|
87
|
+
|
51
88
|
```
|
52
|
-
```
|
53
89
|
|
54
90
|
### 試したこと
|
55
91
|
|
1
誤字
title
CHANGED
File without changes
|
body
CHANGED
@@ -20,11 +20,36 @@
|
|
20
20
|
### 該当のソースコード
|
21
21
|
|
22
22
|
```swift
|
23
|
+
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
23
|
-
|
24
|
+
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! TimeLineCell
|
24
|
-
|
25
|
+
cell.timeLineModel = self.timeLines[indexPath.row]
|
26
|
+
|
27
|
+
return cell
|
28
|
+
}
|
29
|
+
|
30
|
+
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
31
|
+
|
32
|
+
let selectedCell = tableView.cellForRow(at: indexPath)
|
33
|
+
musicName = timeLines[indexPath.row].musicName
|
25
|
-
|
34
|
+
groupName = timeLines[indexPath.row].groupName
|
35
|
+
constitution = timeLines[indexPath.row].constitution
|
36
|
+
|
37
|
+
performSegue(withIdentifier: "detail", sender: nil)
|
38
|
+
}
|
39
|
+
|
40
|
+
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
41
|
+
|
26
|
-
|
42
|
+
if segue.identifier == "detail" {
|
43
|
+
|
44
|
+
let detailViewController = segue.destination as! DetailViewController
|
45
|
+
|
46
|
+
detailViewController.musicName = musicName
|
47
|
+
detailViewController.groupName = groupName
|
48
|
+
detailViewController.constitution = constitution
|
49
|
+
}
|
50
|
+
|
27
51
|
```
|
52
|
+
```
|
28
53
|
|
29
54
|
### 試したこと
|
30
55
|
|