Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
Nick A.23
10 years agoNew member | Level 1
In the DropboxSDK for iOS, are DBRestClients required to be an instance variable of a UIViewController?
I am using the DropboxSDK for iOS, and I am trying to have a Dropbox fetch occur inside viewDidAppear(animated:). However, whenever I create a local DBRestClient inside viewDidAppear and call loadMetadata(forPath:), the delegate methods are never called. I am not presented with any errors or anything. It simply seems as though no requests were made. Being in viewDidAppear, the client should have been on the UI thread which has a run loop. I also tried explicitly asking GCD to run the declaration of the client as well as the loadMetadata call on the main thread but that did not work either.
In a desperate attempt to figure out what was wrong, I followed the tutorial to an absolute tee and the only difference was that the tutorial had the DBRestClient as an instance variable on the UIViewController. I thought there was no way that could actually be the problem. I pulled my DBRestClient variable out as an instance variable and sure enough everything worked suddenly.
My question is: why does the DBRestClient have to be an instance variable on a UIViewController?
Note: I am using Swift with an ObjC Bridging Header, but this should not have any affect on the actual workings of the code to my knowledge.
1 Reply
- Steve M.10 years ago
Dropbox Staff
Your DBRestClient instance presumably went out of scope at the end of viewWillDisappear, so the object got deleted. Although you don't necessarily need it to be an instance variable on a UIViewController, it does need to be retained somehow.
I should point out that the API you're using has been deprecated and will stop working next year. See https://blogs.dropbox.com/developers/2016/06/api-v1-deprecated/ for details.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!