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

質問編集履歴

2

誤字

2019/10/16 03:33

投稿

tttttttnaga
tttttttnaga

スコア7

title CHANGED
File without changes
body CHANGED
@@ -44,8 +44,8 @@
44
44
 
45
45
  required init?(coder aDecoder: NSCoder) {
46
46
  todo = aDecoder.decodeObject(forKey: "todo") as! String
47
- estimate = aDecoder.decodeInteger(forKey: "time1")
47
+ time1 = aDecoder.decodeInteger(forKey: "time1")
48
- actual = aDecoder.decodeInteger(forKey: "time2")
48
+ time2 = aDecoder.decodeInteger(forKey: "time2")
49
49
  date = aDecoder.decodeObject(forKey: "date") as! Date
50
50
  }
51
51
  }

1

変数の更新

2019/10/16 03:33

投稿

tttttttnaga
tttttttnaga

スコア7

title CHANGED
File without changes
body CHANGED
@@ -12,8 +12,8 @@
12
12
  受け渡したいデータは、以下の4つで、これらを格納するカスタムクラスをUserDefaultsで取り扱いたいです。
13
13
 
14
14
  1.todo : String
15
- 2.estimate : Int
15
+ 2.time1 : Int
16
- 3.actual : Int
16
+ 3.time2 : Int
17
17
  4.date : Date
18
18
 
19
19
  ### 該当のソースコード
@@ -24,28 +24,28 @@
24
24
  class Content:NSObject, NSCoding {
25
25
 
26
26
  let todo: String
27
- let estimate: Int
27
+ let time1: Int
28
- let actual: Int
28
+ let time2: Int
29
29
  let date: Date
30
30
 
31
- init(todo:String, estimate:Int, actual:Int, date:Date) {
31
+ init(todo:String, time1:Int, time2:Int, date:Date) {
32
32
  self.todo = todo
33
- self.estimate = estimate
33
+ self.time1 = time1
34
- self.actual = actual
34
+ self.time2 = time2
35
35
  self.date = date
36
36
  }
37
37
 
38
38
  func encode(with aCoder: NSCoder) {
39
39
  aCoder.encode(self.todo, forKey: "todo")
40
- aCoder.encode(self.estimate, forKey: "estimate")
40
+ aCoder.encode(self.estimate, forKey: "time1")
41
- aCoder.encode(self.actual, forKey: "actual")
41
+ aCoder.encode(self.actual, forKey: "time2")
42
42
  aCoder.encode(self.date, forKey: "date")
43
43
  }
44
44
 
45
45
  required init?(coder aDecoder: NSCoder) {
46
46
  todo = aDecoder.decodeObject(forKey: "todo") as! String
47
- estimate = aDecoder.decodeInteger(forKey: "estimate")
47
+ estimate = aDecoder.decodeInteger(forKey: "time1")
48
- actual = aDecoder.decodeInteger(forKey: "actual")
48
+ actual = aDecoder.decodeInteger(forKey: "time2")
49
49
  date = aDecoder.decodeObject(forKey: "date") as! Date
50
50
  }
51
51
  }
@@ -69,13 +69,13 @@
69
69
  timer.invalidate()
70
70
 
71
71
  let todoString:String = todo.text!
72
- var estimateInt:Int = Int()
72
+ var time1Int:Int = Int()
73
- var auctualInt:Int = Int()
73
+ var time2Int:Int = Int()
74
74
  let now:Date = Date()
75
75
 
76
- let index = timePickerOption.firstIndex(of: estimateTime.text!)
76
+ let index = timePickerOption.firstIndex(of: timeLabel.text!)
77
- estimateInt = convertedTimePickerOption[index!]
77
+ time1Int = convertedTimePickerOption[index!]
78
- actualInt = estimateInt - count
78
+ time2Int = time1Int - count
79
79
 
80
80
  // done!押下時の時間を"yyyy/mm/dd"に変換する
81
81
  let f = DateFormatter()
@@ -86,7 +86,7 @@
86
86
  let s = f.string(from: now)
87
87
 
88
88
  // contentに書き込み、contentsにappend
89
- content = [Content(todo: todoString, estimate: estimateInt, actual: actualInt, date: f.date(from: s)!)]
89
+ content = [Content(todo: todoString, time1: time1Int, time2: time2Int, date: f.date(from: s)!)]
90
90
  contents.append(content)
91
91
 
92
92
  // UserDefaultsに保存