• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Best way to have KVC-compliant enum property in Swift 2?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Best way to have KVC-compliant enum property in Swift 2?
      • From: Quincey Morris <email@hidden>
    • Re: Best way to have KVC-compliant enum property in Swift 2?
      • From: Charles Srstka <email@hidden>
  • Prev by Date: Re: Codesigning issues
  • Next by Date: Re: Best way to have KVC-compliant enum property in Swift 2?
  • Previous by thread: Re: Obj-c to Swift conversion question
  • Next by thread: Re: Best way to have KVC-compliant enum property in Swift 2?
  • Index(es):
    • Date
    • Thread