ios개발/개념 정리

<스위프트>수정중, UrlSessionTask를 resume,cancel,suspend해보자.!!!

studying develop 2020. 3. 24. 16:28

How to stop/cancel/suspend/resume tasks on GCD queue

 

[https://stackoverflow.com/questions/29492707/how-to-stop-cancel-suspend-resume-tasks-on-gcd-queue]

 

You can't pause / cancel when using a GCD queue. If you need that functionality (and in a lot of general cases even if you don't) you should be using the higher level API - NSOperationQueue. This is built on top of GCD but it gives you the ability to control how many things are executing at the same time, suspend processing of the queue and to cancel individual / all operations.

 

I agree with the NSOperationQueue advice, but on the technical matter, iOS 8 added cancellation capabilities of GCD. See Power, Performance and Diagnostics: What's new in GCD and XPC. – Rob Apr 7 '15 at 13:35

 

그니까 위의 분들 말은 cancel은 되고 suspend는 안되더라 인데, 난 둘다 실패했습니다. 멀티 스레딩 환경에서 그래서 단일 스레드로 플레이그라운드에서 곧 다시 시도해 볼 것입니다.

 


이거 다시 시도해 본다. (2020.04.05) , 새롭게 브랜치를 만들어서 시도한다. 그게 기록도 여러개 남고 구분하기 편해서 좋아 보인다. 혼자할때도

 

[https://melod-it.gitbook.io/sagwa/app-frameworks/foundation/url-loading-system/urlsessiontask] 일단 문서상 suspend가 중지 시키는게 맞고 ,task의 상태를 볼 수 있는 다른 변수들도 있다.

 

하 설계는 했는데, 디버깅이 어렵다. 근데 디버깅을 떠나서 잘안되는거 같다.

 

task appended
task appended
2020-04-05 17:30:18.427355+0900 kakao_subject_kimdonghwan[6429:148314] [reports] Main Thread Checker: UI API called on a background thread: -[UIViewController presentedViewController]
PID: 6429, TID: 148314, Thread name: (none), Queue name: com.apple.root.user-initiated-qos, QoS: 25
Backtrace:
4   kakao_subject_kimdonghwan           0x000000010f69b2d6 $sSo13UIApplicationC25kakao_subject_kimdonghwanE17topViewController10controllerSo06UIViewG0CSgAH_tFZ + 966
5   kakao_subject_kimdonghwan           0x000000010f69b092 $sSo13UIApplicationC25kakao_subject_kimdonghwanE17topViewController10controllerSo06UIViewG0CSgAH_tFZ + 386
6   kakao_subject_kimdonghwan           0x000000010f6a43dc $s25kakao_subject_kimdonghwan10CustomCellC8getImage5group8imageUrlySo012OS_dispatch_H0C_SStFyycfU_ + 1404
7   kakao_subject_kimdonghwan           0x000000010f693fb0 $sIeg_IeyB_TR + 48
8   libdispatch.dylib                   0x000000010fbddf11 _dispatch_call_block_and_release + 12
9   libdispatch.dylib                   0x000000010fbdee8e _dispatch_client_callout + 8
10  libdispatch.dylib                   0x000000010fbf0724 _dispatch_root_queue_drain + 1258
11  libdispatch.dylib                   0x000000010fbf0ca6 _dispatch_worker_thread2 + 135
12  libsystem_pthread.dylib             0x00007fff51b9f6b6 _pthread_wqthread + 220
13  libsystem_pthread.dylib             0x00007fff51b9e827 start_wqthread + 15
2020-04-05 17:30:18.427381+0900 kakao_subject_kimdonghwan[6429:148246] [reports] Main Thread Checker: UI API called on a background thread: -[UINavigationController visibleViewController]
PID: 6429, TID: 148246, Thread name: (none), Queue name: com.apple.root.user-initiated-qos, QoS: 25
Backtrace:
4   kakao_subject_kimdonghwan           0x000000010f69b077 $sSo13UIApplicationC25kakao_subject_kimdonghwanE17topViewController10controllerSo06UIViewG0CSgAH_tFZ + 359
5   kakao_subject_kimdonghwan           0x000000010f6a43dc $s25kakao_subject_kimdonghwan10CustomCellC8getImage5group8imageUrlySo012OS_dispatch_H0C_SStFyycfU_ + 1404
6   kakao_subject_kimdonghwan           0x000000010f693fb0 $sIeg_IeyB_TR + 48
7   libdispatch.dylib                   0x000000010fbddf11 _dispatch_call_block_and_release + 12
8   libdispatch.dylib                   0x000000010fbdee8e _dispatch_client_callout + 8
9   libdispatch.dylib                   0x000000010fbf0724 _dispatch_root_queue_drain + 1258
10  libdispatch.dylib                   0x000000010fbf0ca6 _dispatch_worker_thread2 + 135
11  libsystem_pthread.dylib             0x00007fff51b9f6b6 _pthread_wqthread + 220
12  libsystem_pthread.dylib             0x00007fff51b9e827 start_wqthread + 15
task appended
task appended
task appended
task in: Optional(<NSProgress: 0x600000608000> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000620c80> : Parent: 0x600000608000 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000620b40> : Parent: 0x600000608000 (portion: 95) / Fraction completed: 0.0000 / Completed: 0 of 100  ) 

task in: Optional(<NSProgress: 0x60000062ce60> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x6000006045a0> : Parent: 0x60000062ce60 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000638000> : Parent: 0x60000062ce60 (portion: 95) / Fraction completed: 0.0000 / Completed: 0 of 100  ) 

task in: Optional(<NSProgress: 0x600000628aa0> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000604640> : Parent: 0x600000628aa0 (portion: 95) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x6000006248c0> : Parent: 0x600000628aa0 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  ) 

task in: Optional(<NSProgress: 0x6000006046e0> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000604780> : Parent: 0x6000006046e0 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000604820> : Parent: 0x6000006046e0 (portion: 95) / Fraction completed: 0.0000 / Completed: 0 of -1  ) 

task in: Optional(<NSProgress: 0x60000062cdc0> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x6000006340a0> : Parent: 0x60000062cdc0 (portion: 95) / Fraction completed: 0.0000 / Completed: 317828 of -1  
  <NSProgress: 0x600000628a00> : Parent: 0x60000062cdc0 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  ) 

task in: Optional(<NSProgress: 0x600000628960> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x60000062cbe0> : Parent: 0x600000628960 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x60000062cb40> : Parent: 0x600000628960 (portion: 95) / Fraction completed: 0.0000 / Completed: 0 of 100  ) 

task in: Optional(<NSProgress: 0x60000062cd20> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x6000006048c0> : Parent: 0x60000062cd20 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x6000006080a0> : Parent: 0x60000062cd20 (portion: 95) / Fraction completed: 0.0000 / Completed: 0 of 100  ) 

task in: Optional(<NSProgress: 0x60000062cc80> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000624960> : Parent: 0x60000062cc80 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000624a00> : Parent: 0x60000062cc80 (portion: 95) / Fraction completed: 0.0000 / Completed: 130205 of -1  ) 

task in: Optional(<NSProgress: 0x600000634000> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x6000006380a0> : Parent: 0x600000634000 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000638140> : Parent: 0x600000634000 (portion: 95) / Fraction completed: 0.0000 / Completed: 0 of 100  ) 

task in: Optional(<NSProgress: 0x600000624820> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000634140> : Parent: 0x600000624820 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x6000006341e0> : Parent: 0x600000624820 (portion: 95) / Fraction completed: 0.0000 / Completed: 0 of 100  ) 

task out: Optional(<NSProgress: 0x60000062cc80> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000624960> : Parent: 0x60000062cc80 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000624a00> : Parent: 0x60000062cc80 (portion: 95) / Fraction completed: 0.0000 / Completed: 130205 of -1  ) 

task out: Optional(<NSProgress: 0x60000062cdc0> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0500 / Completed: 5 of 100  
  <NSProgress: 0x6000006340a0> : Parent: 0x60000062cdc0 (portion: 95) / Fraction completed: 0.0000 / Completed: -1 of -1  ) 

task out: Optional(<NSProgress: 0x6000006046e0> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0500 / Completed: 5 of 100  
  <NSProgress: 0x600000604820> : Parent: 0x6000006046e0 (portion: 95) / Fraction completed: 0.0000 / Completed: -1 of -1  ) 

task out: Optional(<NSProgress: 0x600000628960> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

task out: Optional(<NSProgress: 0x60000062ce60> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

task out: Optional(<NSProgress: 0x600000628aa0> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

task out: Optional(<NSProgress: 0x600000608000> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

task out: Optional(<NSProgress: 0x600000634000> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

task out: Optional(<NSProgress: 0x60000062cd20> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

task out: Optional(<NSProgress: 0x600000624820> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

Optional(LocalDataTask <74D74919-692D-465B-815E-CA2F8781AB91>.<8>) before suspended: Optional(<NSProgress: 0x600000608000> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

Optional(LocalDataTask <74D74919-692D-465B-815E-CA2F8781AB91>.<8>) after suspended: Optional(<NSProgress: 0x600000608000> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

Optional(LocalDataTask <8870033F-45A9-48C5-A63D-AC254ACB8C1E>.<9>) before suspended: Optional(<NSProgress: 0x600000634000> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

Optional(LocalDataTask <8870033F-45A9-48C5-A63D-AC254ACB8C1E>.<9>) after suspended: Optional(<NSProgress: 0x600000634000> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

Optional(LocalDataTask <089B5857-96C7-42CD-BB4C-1837D4A26264>.<10>) before suspended: Optional(<NSProgress: 0x60000062cd20> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

Optional(LocalDataTask <089B5857-96C7-42CD-BB4C-1837D4A26264>.<10>) after suspended: Optional(<NSProgress: 0x60000062cd20> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

Optional(LocalDataTask <EA8E287F-189B-4185-B8A0-2C259FD37A67>.<11>) before suspended: Optional(<NSProgress: 0x600000624820> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

Optional(LocalDataTask <EA8E287F-189B-4185-B8A0-2C259FD37A67>.<11>) after suspended: Optional(<NSProgress: 0x600000624820> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

Optional(LocalDataTask <59B4D678-B6C7-4FCE-9DB8-A8CDC9192782>.<2>) before suspended: Optional(<NSProgress: 0x60000062cc80> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000624960> : Parent: 0x60000062cc80 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000624a00> : Parent: 0x60000062cc80 (portion: 95) / Fraction completed: 0.0000 / Completed: 130205 of -1  ) 

Optional(LocalDataTask <59B4D678-B6C7-4FCE-9DB8-A8CDC9192782>.<2>) after suspended: Optional(<NSProgress: 0x60000062cc80> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000624960> : Parent: 0x60000062cc80 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000624a00> : Parent: 0x60000062cc80 (portion: 95) / Fraction completed: 0.0000 / Completed: 130205 of -1  ) 

Optional(LocalDataTask <6FA16B8C-EDE0-43F5-9D12-A5DBD8C13BB6>.<3>) before suspended: Optional(<NSProgress: 0x60000062cdc0> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0500 / Completed: 5 of 100  
  <NSProgress: 0x6000006340a0> : Parent: 0x60000062cdc0 (portion: 95) / Fraction completed: 0.0000 / Completed: -1 of -1  ) 

Optional(LocalDataTask <6FA16B8C-EDE0-43F5-9D12-A5DBD8C13BB6>.<3>) after suspended: Optional(<NSProgress: 0x60000062cdc0> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0500 / Completed: 5 of 100  
  <NSProgress: 0x6000006340a0> : Parent: 0x60000062cdc0 (portion: 95) / Fraction completed: 0.0000 / Completed: -1 of -1  ) 

Optional(LocalDataTask <0C4DD833-2853-4D7E-A317-47ED45193391>.<4>) before suspended: Optional(<NSProgress: 0x6000006046e0> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0500 / Completed: 5 of 100  
  <NSProgress: 0x600000604820> : Parent: 0x6000006046e0 (portion: 95) / Fraction completed: 0.0000 / Completed: -1 of -1  ) 

Optional(LocalDataTask <0C4DD833-2853-4D7E-A317-47ED45193391>.<4>) after suspended: Optional(<NSProgress: 0x6000006046e0> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0500 / Completed: 5 of 100  
  <NSProgress: 0x600000604820> : Parent: 0x6000006046e0 (portion: 95) / Fraction completed: 0.0000 / Completed: -1 of -1  ) 

Optional(LocalDataTask <6F66FCE5-E5C8-41D9-8CF8-F68E4126D599>.<5>) before suspended: Optional(<NSProgress: 0x600000628960> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

Optional(LocalDataTask <6F66FCE5-E5C8-41D9-8CF8-F68E4126D599>.<5>) after suspended: Optional(<NSProgress: 0x600000628960> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

task in: Optional(<NSProgress: 0x600000604640> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000604960> : Parent: 0x600000604640 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x6000006043c0> : Parent: 0x600000604640 (portion: 95) / Fraction completed: 0.0000 / Completed: 0 of 100  ) 

task in: Optional(<NSProgress: 0x600000629360> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x6000006292c0> : Parent: 0x600000629360 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x6000006290e0> : Parent: 0x600000629360 (portion: 95) / Fraction completed: 0.0000 / Completed: 0 of 100  ) 

task in: Optional(<NSProgress: 0x600000608140> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000608280> : Parent: 0x600000608140 (portion: 95) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x6000006081e0> : Parent: 0x600000608140 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  ) 

task in: Optional(<NSProgress: 0x600000629040> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x6000006288c0> : Parent: 0x600000629040 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000628820> : Parent: 0x600000629040 (portion: 95) / Fraction completed: 0.0000 / Completed: 0 of 100  ) 

task in: Optional(<NSProgress: 0x600000630a00> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000630780> : Parent: 0x600000630a00 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000630960> : Parent: 0x600000630a00 (portion: 95) / Fraction completed: 0.0000 / Completed: 0 of 100  ) 

task in: Optional(<NSProgress: 0x600000621220> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000621180> : Parent: 0x600000621220 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000621040> : Parent: 0x600000621220 (portion: 95) / Fraction completed: 0.0000 / Completed: 0 of 100  ) 

task in: Optional(<NSProgress: 0x600000630aa0> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000630b40> : Parent: 0x600000630aa0 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000630be0> : Parent: 0x600000630aa0 (portion: 95) / Fraction completed: 0.0000 / Completed: 0 of 100  ) 

task in: Optional(<NSProgress: 0x600000620fa0> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000620e60> : Parent: 0x600000620fa0 (portion: 95) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000620f00> : Parent: 0x600000620fa0 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  ) 

task in: Optional(<NSProgress: 0x60000062d2c0> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x60000062d180> : Parent: 0x60000062d2c0 (portion: 95) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x60000062d220> : Parent: 0x60000062d2c0 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  ) 

task in: Optional(<NSProgress: 0x600000630c80> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000630d20> : Parent: 0x600000630c80 (portion: 5) / Fraction completed: 0.0000 / Completed: 0 of 100  
  <NSProgress: 0x600000630dc0> : Parent: 0x600000630c80 (portion: 95) / Fraction completed: 0.0000 / Completed: 0 of 100  ) 

task out: Optional(<NSProgress: 0x600000604640> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

task out: Optional(<NSProgress: 0x600000630a00> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

task out: Optional(<NSProgress: 0x600000608140> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

task out: Optional(<NSProgress: 0x600000629040> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

task out: Optional(<NSProgress: 0x600000629360> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

task out: Optional(<NSProgress: 0x600000621220> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

task out: Optional(<NSProgress: 0x600000630aa0> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

task out: Optional(<NSProgress: 0x60000062d2c0> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

task out: Optional(<NSProgress: 0x600000620fa0> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

task out: Optional(<NSProgress: 0x600000630c80> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

 

 

다시 해보려는데

 

UnsafeMutablePointer.deinitialize with negative count 일단 이 에러는, 멀티 스레드 환경이라 변수 safe하게 세마포로 설정하자.

 

그리고 이번에 확인은 UrlSessionTask.state로 상태를 확인하자, progress는 진척 상황 확인하긴 좋은데, 그정도로 아직 필요 없음 디버깅에.

 

 

일단 다시 이렇게 했다.

 

print("after suspended state : \(String(describing: task!.state)) \n")

after suspended state : NSURLSessionTaskState 왜 이렇게 뜨지? 상태를 제대로 볼 수 가 없는건가??

 

이건데 제대로 사용 못한건가, 리턴이 enum이라 그런거 같다.

 

결론적으로 말하자면 suspend에 성공했다. 좀 고친 디버깅 방법은 state가 enum인거 나중에 알아서 분기 처리로 확인했고 , 그걸 이용해 중간에 suspend되는 urlTask를 발견했다. 

 

그런데 의문은 이게 더 빠른지는 모르겠다.... suspend가 되는게 바로 다음 urltask를 실행하도록 해주는건가??? 이부분을 확인해야 될듯;

 

일단 정리하면

 

if task!.state == .suspended{
	print("is suspended\n")
}else if task!.state == .running{
	print("is running\n")
}else if task!.state == .canceling{
    print("is canceling \n")
}else if task!.state == .completed{
	print("is completed \n")
}
after suspended

is suspended
in task out: Optional(<NSProgress: 0x600003ad5cc0> : Parent: 0x0 (portion: 0) / Fraction completed: 1.0000 / Completed: 100 of 100  ) 

is completed 

중지와 완료되는건 확인했ㅇ다.

 

근데 음 더 빠른지 아닌지 알려면 어떻게 해야 될까?