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

質問編集履歴

3

警告が出ました

2017/01/06 09:26

投稿

comet0310
comet0310

スコア59

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

2

更新しました

2017/01/06 09:26

投稿

comet0310
comet0310

スコア59

title CHANGED
File without changes
body CHANGED
@@ -21,7 +21,8 @@
21
21
 
22
22
  return true
23
23
  }
24
- func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
24
+ private func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
25
+ print("enter")
25
26
  let now = NSDate()
26
27
 
27
28
  let formatter = DateFormatter()
@@ -29,10 +30,9 @@
29
30
 
30
31
  let string = formatter.string(from: now as Date)
31
32
 
32
- print(string)
33
+ print(string+"ifhdoifgodhgoidhfoihf")
33
34
  completionHandler(UIBackgroundFetchResult.newData)
34
35
  }
35
-
36
36
 
37
37
  func applicationWillResignActive(_ application: UIApplication) {
38
38
  // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
@@ -59,4 +59,6 @@
59
59
 
60
60
  }
61
61
 
62
+
63
+
62
64
  ```

1

読みやすくしました

2017/01/06 09:15

投稿

comet0310
comet0310

スコア59

title CHANGED
File without changes
body CHANGED
@@ -19,7 +19,6 @@
19
19
  // Override point for customization after application launch.
20
20
  UIApplication.shared.setMinimumBackgroundFetchInterval(UIApplicationBackgroundFetchIntervalMinimum)
21
21
 
22
- //application.setMinimumBackgroundFetchInterval(UIApplicationBackgroundFetchIntervalMinimum)
23
22
  return true
24
23
  }
25
24
  func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
@@ -33,25 +32,7 @@
33
32
  print(string)
34
33
  completionHandler(UIBackgroundFetchResult.newData)
35
34
  }
36
- /*private func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
35
+
37
-
38
- // ダウンロードなどの処理
39
- let now = NSDate()
40
- let formatter = DateFormatter()
41
- formatter.dateFormat = "hh:mm:ss"
42
- let currentTime = formatter.string(from: now as Date)
43
- print("im on")
44
- // Keyを指定して読み込み
45
- var rec: String = userDefaults.object(forKey: "Record") as! String
46
-
47
- rec = rec + currentTime + "\n"
48
-
49
- // Keyを指定して保存
50
- userDefaults.set(rec , forKey: "Record")
51
- userDefaults.synchronize()
52
- completionHandler(UIBackgroundFetchResult.newData)
53
-
54
- }*/
55
36
 
56
37
  func applicationWillResignActive(_ application: UIApplication) {
57
38
  // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.