-
Notifications
You must be signed in to change notification settings - Fork 88
Get Progress without KVO #47
Comments
Hi @manikkalra the only way to get progress on an upload is with the NSProgress object on the upload task. Can you provide an example of how you are attaching the observer? We can discuss other methods of obtaining progress for upload/download/async methods if you have suggestions. |
This is how I am using it. The class I am using it is a shared instance. So, I needed to find a way to remove the observer without deallocating the class. Hence, I removed the observer right before I added it again (this method is called every-time I upload). Is there something I may be missing?
And here is how I remove the observer:
|
Are you sure that the removeOberserver is getting called and not failing? You are catching an exception and not doing anything with it. |
If the observer is not yet set up, I expect it to fail. However, the removeObserver call will crash the app if not caught, and hence the empty catch statement. |
You are calling removeOvserver before you have attached the observer. You need to remove the observer after the upload is complete. |
Here's what I am doing now. I'll test it a little more (KVO stops working after the app has been in the background for a while)
|
So after some testing, the progress does not work after the app has gone into the background a few times. Any advice for me? |
I haven't been able to reproduce your issue here, Can you try setting self.uploadTask to nil after your remove the observer? |
I will try that and let you know. Thank you! |
I tired that but unfortunately it doesn't help :\ |
Hi @manikkalra, |
Is there anyway to get upload progress without KVO? I am getting weird behavior when the app stays in the background too long. I remove the observer before I deallocate, but that doesn't seem to help. Closing the app and reopening fixes that issue.
The text was updated successfully, but these errors were encountered: