NSURLSessionDataTask dataTaskWithURL completion handler not getting called

后端 未结 2 567
梦毁少年i
梦毁少年i 2020-12-03 15:00

I have been learning Objective C lately, and I decided to try connections.

Everything was great with NSURLConnection, until I discovered it was outdated, and tried t

2条回答
  •  悲哀的现实
    2020-12-03 15:58

    Check the location of your code.

    Although it is not stated in OP where the code was located, I found, after much looking and many iterations, that putting sample code in -viewDidLoad never executed the completion handler. Moving the code into

    - (void)viewWillAppear:(BOOL)animated { }
    

    solved the never completing task issue. (I still don't understand why though.)

提交回复
热议问题