NSURLConnection does not call complete across multiple Views

前端 未结 5 481
感动是毒
感动是毒 2021-01-29 03:07

Earlier today I asked the following question: iOS block being stoped when view pushed

The operation I mentioned (OP1) is actually a \"http get\" to my server, using NSUR

5条回答
  •  礼貌的吻别
    2021-01-29 03:24

    So, here is what I think will work for sure:

    Pass the flag to the new controller. If the flag is unfinished, then start over loading in the new VC and make sure none of the data shows up until it is done loading.

    I do think it is weird that the thread stops though, with the new VC being pushed, because when I dispatch asynchronous calls with AFNetworking, it does continue to load even after a new VC is pushed. Perhaps if you are using a different framework, you should use AFNetworking.

    So, if your thread actually does continue after the new VC is pushed on (as I suspect it does - you just think it doesn't keep going because it crashes the code), then try the following:

    a) pass flag, if operation finished, proceed normally
    b) if not, don't load anything and invoke some kind of delegate method between the two that checks if the flag is set, and returns the data if so.

    If you have questions on how to set up a delegate, just ask and I can fill in some details on that.

提交回复
热议问题