Best way to have KVC-compliant enum property in Swift 2?
Best way to have KVC-compliant enum property in Swift 2?
- Subject: Best way to have KVC-compliant enum property in Swift 2?
- From: Rick Mann <email@hidden>
- Date: Tue, 28 Jul 2015 18:07:36 -0700
I'd like to have a Swift enum that lays out a set of states, and a property of that type on an object that is KVObservable (i.e. dynamic). I don't think this is possible. What I settled on was this:
class
Model : MPObject
{
enum
DownloadState : NSNumber
{
case notDownloaded = 0
case downloadStarted = 1
case downloadComplete = 2
case downloadError = 3
}
dynamic var thumbnailURL : NSURL?
dynamic var numFiles : NSNumber?
dynamic var filesDownloaded : NSNumber?
dynamic var downloadState : NSNumber? = DownloadState.notDownloaded.rawValue
}
But that's kinda gross. Any better approaches? Thanks!
--
Rick Mann
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden