Tag: enums

如何将Swift enum:String转换为Objective-C枚举:NSString?

我有一个问题将此快速枚举转换为Objective-C: public enum ISO8601Format: String { case Year = "yyyy" // 1997 case YearMonth = "yyyy-MM" // 1997-07 case Date = "yyyy-MM-dd" // 1997-07-16 case DateTime = "yyyy-MM-dd'T'HH:mmZ" // 1997-07-16T19:20+01:00 case DateTimeSec = "yyyy-MM-dd'T'HH:mm:ssZ" // 1997-07-16T19:20:30+01:00 case DateTimeMilliSec = "yyyy-MM-dd'T'HH:mm:ss.SSSZ" // 1997-07-16T19:20:30.45+01:00 init(dateString:String) { switch dateString.characters.count { case 4: self = ISO8601Format(rawValue: ISO8601Format.Year.rawValue)! case 7: […]

如何简化和使用枚举,快速学习,枚举更好

我正在通过以下来定义一些范围 let range0_15 = 0 ..< 15 let range15_30 = 15 ..< 30 let range30_45 = 30 ..< 45 let range45_60 = 45 ..< 60 我真的想通过尝试使用Enum enum range : Range<Int> { range0_15 = 0 ..< 15 range15_30 = 15 ..< 30 range30_45 = 30 ..< 45 range45_60 = 45 ..< 60 } 我收到一个错误 Type 'CoreDataStach.range' […]

在types中找不到枚举大小写开关

有人可以帮助我这个。 我有以下的public enum public enum OfferViewRow { case Candidates case Expiration case Description case Timing case Money case Payment } 和下面的mutableProperty: private let rows = MutableProperty<[OfferViewRow]>([OfferViewRow]()) 在我的init文件中,我使用一些reactiveCocoa来设置我的MutableProperty: rows <~ application.producer .map { response in if response?.application.status == .Applied { return [.Candidates, .Description, .Timing, .Money, .Payment] } else { return [.Candidates, .Expiration, .Description, .Timing, .Money, .Payment] […]

添加字段在Swift中枚举

我在Swift中处理enum和subclassing。 每个孩子带来自己的新的属性,必须存储在一个枚举。 这个枚举在母类中被声明为有一些值。 我想为这个枚举添加一些值。 我无法find如何做到这一点,我试图没有结果: extension MotherClass { enum Enumeration { case NewProperty } }

如何通过@objc标签传递快速枚举

我需要定义一个可以在一个使用Objective-ctypes的类中调用的协议 但是这样做不起作用: enum NewsCellActionType: Int { case Vote = 0 case Comments case Time } @objc protocol NewsCellDelegate { func newsCellDidSelectButton(cell: NewsCell, actionType: NewsCellActionType) } 你得到他的错误 Swift enums cannot be represented in Objective-C 如果我没有把@objc标签放在我的协议上,只要在一个类中调用应用程序就会使应用程序崩溃,这个类采用了从Objective-C类类(如UIViewController)inheritance的协议。 所以我的问题是,我应该如何声明并通过@objc标签传递我的枚举?