4964

[code]

    enum Num: String{
        case Zero = "0", One = "1", Two = "2", Three = "3", Four = "4", Five = "5", Six = "6", Seven = "7", Eight = "8", Nine = "9", Ten = "10", Eleven = "11", Twelve = "12"
    }
    
[/code]

このようなenumがあった場合にfor inさせるにはどのような方法がありますか？


CC BY-SA 3.0
2015-01-21T03:12:29.800
4943
2015-01-21T05:28:36.127
2772
question
swift
Swift の enum型を for-inする方法


少し違うかもしれませんが、英語版で似た質問を見つけました。  
<https://stackoverflow.com/questions/24007461/how-to-enumerate-an-enum-with-
string-type>

// 英語版から転載

[code]

    enum ProductCategory : String {
         case Washers = "washers", Dryers = "dryers", Toasters = "toasters"
    
         static let allValues = [Washers, Dryers, Toasters]
    }
    
    for category in ProductCategory.allValues{
         //Do something
    }
    
[/code]


CC BY-SA 3.0
2015-01-21T05:28:36.127
4964
2015-01-21T05:28:36.127
2017-05-23T12:38:55.250
-1
3516
4943
answer