We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
RJKinsman
7 years agoHelpful | Level 6
Capturing serverModified into a variable in Swift
I'm new to Swift, and this is my first iOS application. In fact, I'm fairly new to OO programming. My background is mainframe z/OS. So... I needed to capture serverModified date in a field. Afte...
- 7 years ago
Thanks, Greg! So much cleaner!
Greg-DB
Dropbox Community Moderator
7 years agoHere's the recommended way to get the serverModified out of a Metadata object given by filesGetMetadata:
client!.files.getMetadata(path: path)
.response {response, error in
if let (metadata) = response {
switch metadata {
case let fileMetadata as Files.FileMetadata:
print("File metadata: \(fileMetadata)")
let serverModified = fileMetadata.serverModified
print("File serverModified: \(serverModified)")
case let folderMetadata as Files.FolderMetadata:
print("Folder metadata: \(folderMetadata)")
// folders don't have serverModified
case let deletedMetadata as Files.DeletedMetadata:
print("Deleted entity's metadata: \(deletedMetadata)")
// deleted entries don't have serverModified
default:
print("default")
}
}
else if let error = error {
print(error)
}
}
This method can return metadata for files, folders, or deleted items, so you need to check the type first, done here using the switch, since the latter two don't have serverModified.
Hope this helps!
- RJKinsman7 years agoHelpful | Level 6
Thanks, Greg! So much cleaner!
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!