I need to choose a type for holding object. But I need some help.
My object should have 3 property:
- small
- medium
- max
Each of them will hold URL
Also my object should have Preferred property. Which will be assigned as small, medium or max. And Preferred should return URL from selected property.
For example if I assign:
small = url1
medium = url2
max = url3
//Here also I have global settings class. And in that I should choose to return from preferred - max urls. And for every insnanse preferred should return max.
Class.preferred = Type.max //something like that
print(instanse.preferred) //printed url3
How can I archive that? I can not use Class here, but I am not sure can I archive that with enum?
Sample which does not work
enum VideoType: String {
case min
case med
case max
}
class VideoInstanse {
var min: VideoType
var med: VideoType
var max: VideoType
static var preferred:VideoType!
init(dictionary: [Int : String]) {
min.rawValue = dictionary[1] //error
med.rawValue = dictionary[2]
max.rawValue = dictionary[3]
}
}
Aucun commentaire:
Enregistrer un commentaire