質問編集履歴

3

警告が出ました

2017/01/06 09:26

投稿

comet0310
comet0310

スコア59

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- delegateの部分にこのように記述してコンソールに現在時間を表示しようとしたのですがシミュレータをバックグラウンドで作動させても何の反応もありませんでした。
1
+ ![イメージ説明](537ab499444b80627a02d8036ca6b228.png)delegateの部分にこのように記述してコンソールに現在時間を表示しようとしたのですがシミュレータをバックグラウンドで作動させても何の反応もありませんでした。
2
2
 
3
3
  教えてくださると幸いです。
4
4
 

2

更新しました

2017/01/06 09:26

投稿

comet0310
comet0310

スコア59

test CHANGED
File without changes
test CHANGED
@@ -44,7 +44,9 @@
44
44
 
45
45
  }
46
46
 
47
- func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
47
+ private func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
48
+
49
+ print("enter")
48
50
 
49
51
  let now = NSDate()
50
52
 
@@ -60,13 +62,11 @@
60
62
 
61
63
 
62
64
 
63
- print(string)
65
+ print(string+"ifhdoifgodhgoidhfoihf")
64
66
 
65
67
  completionHandler(UIBackgroundFetchResult.newData)
66
68
 
67
69
  }
68
-
69
-
70
70
 
71
71
 
72
72
 
@@ -120,4 +120,8 @@
120
120
 
121
121
 
122
122
 
123
+
124
+
125
+
126
+
123
127
  ```

1

読みやすくしました

2017/01/06 09:15

投稿

comet0310
comet0310

スコア59

test CHANGED
File without changes
test CHANGED
@@ -40,8 +40,6 @@
40
40
 
41
41
 
42
42
 
43
- //application.setMinimumBackgroundFetchInterval(UIApplicationBackgroundFetchIntervalMinimum)
44
-
45
43
  return true
46
44
 
47
45
  }
@@ -68,43 +66,7 @@
68
66
 
69
67
  }
70
68
 
71
- /*private func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
69
+
72
-
73
-
74
-
75
- // ダウンロードなどの処理
76
-
77
- let now = NSDate()
78
-
79
- let formatter = DateFormatter()
80
-
81
- formatter.dateFormat = "hh:mm:ss"
82
-
83
- let currentTime = formatter.string(from: now as Date)
84
-
85
- print("im on")
86
-
87
- // Keyを指定して読み込み
88
-
89
- var rec: String = userDefaults.object(forKey: "Record") as! String
90
-
91
-
92
-
93
- rec = rec + currentTime + "\n"
94
-
95
-
96
-
97
- // Keyを指定して保存
98
-
99
- userDefaults.set(rec , forKey: "Record")
100
-
101
- userDefaults.synchronize()
102
-
103
- completionHandler(UIBackgroundFetchResult.newData)
104
-
105
-
106
-
107
- }*/
108
70
 
109
71
 
110
72