简体   繁体   中英

How to use Dropbox Sync API enumerations in Swift?

Given a DBFile object, I kept getting compiler errors if I tried to compare the DBFileState to the enumerated values, eg

var file : DBFile = <some file>
var state = file.status.state
if state == DBFileStateUploading { do something }

The compiler error would say that '==' cannot compare (DBFileState, DBFileState)

The answer turned out to be quite simple:

if state.value == DBFileStateUploading.value { do something }

This has something to do with the fact the the Dropbox enumerations are imported C-style enumerations, but this wasn't easy to find.

Just thought I'd share to help anyone else that might be struggling with this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM