Use of delegates in NSOperation

后端 未结 4 860
滥情空心
滥情空心 2021-02-09 23:24

I am trying to make use of CLLocationManager in an NSOperation. As part of this I require the ability to startUpdatingLocation then wait u

4条回答
  •  天命终不由人
    2021-02-10 00:02

    Its going to call the delegate method in the same operation queue as main is running in. And NSOperation queues are serial by default. Your while loop is just spinning forever (because the operation is never cancelled) and the call to your delegate method is sitting in the queue behind it never able to run.

    Get rid of the while loop entirely and let the operation finish. Then when the delegate method is called, if it's cancelled discard the result by returning.

提交回复
热议问题