teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

わかりやすく変更

2019/01/11 01:02

投稿

hahum
hahum

スコア65

title CHANGED
File without changes
body CHANGED
@@ -56,7 +56,7 @@
56
56
 
57
57
  ```
58
58
 
59
- 追記
59
+ 追記 1/11
60
60
 
61
61
  新しいエラーが次の画面であるTableViewに出ています。(Sigabrt)
62
62
  前回同様部品の紐付けは確認いたしました。エラーメッセージは前回同様Could not cast value of type 'NSTaggedPointerString' to 'NSArray' .です。

1

hennkou

2019/01/11 01:02

投稿

hahum
hahum

スコア65

title CHANGED
File without changes
body CHANGED
@@ -54,4 +54,101 @@
54
54
  dateArray1.append(sDate)
55
55
  }
56
56
 
57
+ ```
58
+
59
+ 追記
60
+
61
+ 新しいエラーが次の画面であるTableViewに出ています。(Sigabrt)
62
+ 前回同様部品の紐付けは確認いたしました。エラーメッセージは前回同様Could not cast value of type 'NSTaggedPointerString' to 'NSArray' .です。
63
+
64
+ SaveViewContoroller.swift
65
+ ```swift
66
+ var resultArray2 = [String]()
67
+
68
+ var dateArray2 = [String]()
69
+
70
+ var Array2: [[String]] = []
71
+ ...
72
+ ...
73
+ ...
74
+
75
+
76
+ override func viewDidLoad() {
77
+ super.viewDidLoad()
78
+
79
+
80
+ tableView.delegate = self
81
+ tableView.dataSource = self
82
+
83
+ if UserDefaults.standard.object(forKey: "save") != nil {
84
+
85
+ Array2 = [UserDefaults.standard.object(forKey: "save") as! [String]]
86
+ }
87
+
88
+ Array2 = [resultArray2, dateArray2]
89
+
90
+
91
+ self.resultArray2 = self.Array2[0]
92
+ self.dateArray2 = self.Array2[1]
93
+
94
+
95
+
96
+
97
+ //Array2 = [ ["晴れ", "雨", "雪"],
98
+ //["2019/1/1", "2019/1/2", "2019/1/3"] ]
99
+
100
+ print("Array2:", Array2.description)
101
+ print(resultArray2.description)
102
+ print(dateArray2.description)
103
+
104
+ }
105
+
106
+
107
+ override func viewWillAppear(_ animated: Bool) {
108
+ super.viewDidAppear(animated)
109
+
110
+ tableView.reloadData()
111
+ }
112
+
113
+
114
+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
115
+
116
+ return resultArray2.count
117
+
118
+ }
119
+
120
+ func numberOfSections(in tableView: UITableView) -> Int {
121
+ return 1
122
+ }
123
+
124
+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
125
+ let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
126
+
127
+
128
+ print("Array2:at cellForRowAt", Array2.description)
129
+ print(Array2.count)
130
+ print(resultArray2.description)
131
+ print(dateArray2.description)
132
+
133
+ cell.textLabel!.text = resultArray2[indexPath.row]
134
+ cell.detailTextLabel!.text = dateArray2[indexPath.row]
135
+
136
+ return cell
137
+ }
138
+
139
+ func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
140
+ return 40
141
+ }
142
+
143
+ func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
144
+
145
+ if editingStyle == .delete {
146
+ Array2.remove(at: indexPath.row)
147
+
148
+ UserDefaults.standard.set(Array2, forKey: "save")
149
+
150
+ tableView.reloadData()
151
+ }
152
+ }
153
+
57
154
  ```