We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
joejjank
6 years agoHelpful | Level 6
Mixing Swift and Objective C
I have an application that was first developed for the IPhone and then added support for mac os. Much of this has been developed in Objective C - this is all working fine. As I add new functions I ...
- 6 years ago
Ok - thanks for the feedback. I have some common Objective C in a class that I can call from Swift so that works fine. So until I convert the entire application to swift I can live with that restriction.
joejjank
Helpful | Level 6
Thank Greg - I have both the Objective C and Swift API V2 loaded - is that a problem? The function is in the viewDidLoad - it purpose is the identify the files in my Backup directory on Dropbox and display them in a NSTableView. I am a little confused what I need to use - can you call the Objective C API from Swift?
override func viewDidLoad()
{
super.viewDidLoad()
let obj:DataClassOS = DataClassOS.getInstance()
let client = DropboxClient(accessToken: obj.accesstoken)
_ = client.files.listFolder(path: "/Backup")
.response { response, error in
if let result = response {
print("Folder contents:")
for entry in result.entries {
print(entry.name)
}
} else if let error = error
{
print(error)
}
}
}
Greg-DB
6 years agoDropbox Staff
The SDKs weren't designed with the intention that a single app would use both of them, but I can't say off hand if doing so would or wouldn't cause issues. I don't believe we've explicitly tested that.
You generally can import Objective-C into Swift though. Here's Apple's documentation for doing so:
And here's an old Dropbox blog post that covered how to do so, albeit for an older, now retired SDK:
https://blogs.dropbox.com/developers/2014/09/swift-apps-with-dropbox/
(For the API v2 Objective-C SDK, the import statement is instead "#import <ObjectiveDropboxOfficial/ObjectiveDropboxOfficial.h>".)
If you can get that to work for your app, that might be better, for the sake of simplicity.
In any case, based on the additional code/context you shared here, I think the specific issue you're seeing is just due to the "client" variable going out of scope, since it's only defined in "viewDidLoad". Try moving that out of "viewDidLoad" so that it won't get cleaned up before the API call completes.
- joejjank6 years agoHelpful | Level 6
Ok - thanks for the feedback. I have some common Objective C in a class that I can call from Swift so that works fine. So until I convert the entire application to swift I can live with that restriction.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 12 months agoIf 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 or Facebook.
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!