質問編集履歴

1

コードを追加しました。

2019/08/14 07:46

投稿

kakakawashitax
kakakawashitax

スコア9

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,54 @@
1
+ ```ここに言語を入力
2
+
3
+
4
+
5
+ func time(name: String){
6
+
7
+ let formatter = DateFormatter()
8
+
9
+ formatter.dateFormat = "yyyy/MM/dd HH:mm,ss"
10
+
11
+ var nowTime = formatter.string(from: NSDate() as Date)//ここまでで、現在時刻の取得
12
+
13
+
14
+
15
+ list.insert(name + " " + nowTime, at: 0)
16
+
17
+
18
+
19
+ self.tableView.reloadData()
20
+
21
+
22
+
23
+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
24
+
25
+ return list.count
26
+
27
+ }
28
+
29
+
30
+
31
+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
32
+
33
+ let cell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
34
+
35
+ cell.textLabel!.text = list[indexPath.row]
36
+
37
+ return cell
38
+
39
+ }
40
+
41
+
42
+
43
+ //配列[list]の保存
44
+
45
+ UserDefaults.standard.list = list
46
+
47
+
48
+
49
+ }
50
+
1
- タイムカードのアプリをswiftで作っています。
51
+ ```タイムカードのアプリをswiftで作っています。
2
52
 
3
53
  「開始」「終了」のボタンがあり、そのボタンを押すと、押した瞬間の時刻が画面上のテーブルビューに羅列されていきます。
4
54
 
@@ -8,6 +58,8 @@
8
58
 
9
59
  保存するところから詰まっています。
10
60
 
61
+ 上記のtime()関数で、配列を保存しちゃいたいです。
62
+
11
63
 
12
64
 
13
65
  よろしくお願い致します。