之前已经:
但是有个问题:
当去使用该枚举赋值的时候:
func fromContentTypeOrSuffix(contentTypeOrSuffixStr:String) -> ContentType { var contentType = ContentType.Unknown if !contentTypeOrSuffixStr.isEmpty { let replacedStr = contentTypeOrSuffixStr.replace(“\\/”, to: “/”) print(“replacedStr=\(replacedStr)”) //image/jpeg let splitedStrArr = replacedStr.splitToStrArr(“/”) print(“splitedStrArr=\(splitedStrArr)”) //[“image”, “jpeg”] var secondStrOrSuffix = “” if splitedStrArr.count >= 2 { let firstStr = splitedStrArr[0] switch firstStr.lowercaseString { case “image”: contentType = ContentType.Image contentType = ContentType.Image.Unknown |
出现不兼容:
Cannot assign value of type ‘ContentType.Image.Type’ to type ‘ContentType’
Cannot assign value of type ‘ContentType.Image’ to type ‘ContentType’
swift embedded enum Cannot assign value of type
swift nesting enum Cannot assign value of type
搜:
swift nesting enum content type
The Nesting Rule · Issue #190 · realm/SwiftLint
Using a Nested Type in Swift — Coding Explorer Blog
Nested and Associated Enum Values Swift – Stack Overflow
Swift – Nested Enums default values – Stack Overflow
The Swift Programming Language (Swift 2.2): Nested Types
How do I access an enum from another class in Swift? – Stack Overflow
无法解决。
继续去:
swift enum subclass
转载请注明:在路上 » [未解决]swift中嵌套枚举赋值时出错:Cannot assign value of type ContentType.Image to type ContentType