Skip to content

Instantly share code, notes, and snippets.

@vialyx
Created October 15, 2018 11:34
Show Gist options
  • Select an option

  • Save vialyx/7a3b23e2f2d89896ffbb56d8eec92aa1 to your computer and use it in GitHub Desktop.

Select an option

Save vialyx/7a3b23e2f2d89896ffbb56d8eec92aa1 to your computer and use it in GitHub Desktop.
let mediaSet: [Media] = [Video(url: "http://www_123_@1x.png", thumb: "http://www_123_@1x.png"),
Video(url: "http://www_123_@1x.png", thumb: "http://www_123_@1x.png"),
Media(url: "http://www_123_@1x.png")]
for media in mediaSet {
// We don't sure about casting result
if let video = media as? Video {
print("Video: \(video)")
}
switch media {
case is Video:
// We are sure about casting result, because we checked it before
let video = media as! Video
print("Video: \(video)")
default:
break
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment