This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func fizzBuzz(number: Int) -> String { | |
if number % 3 == 0 && number % 5 == 0 { | |
return "Fizz Buzz" | |
} else { | |
if number % 3 == 0 { | |
return "Fizz" | |
} else { | |
if number % 5 == 0 { | |
return "Buzz" | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func fizzBuzz(number: Int) -> String { | |
switch (number % 3 == 0, number % 5 == 0) { | |
case (true, true): | |
return "Fizz Buzz" | |
case (true, false): | |
return "Fizz" | |
case (false, true): | |
return "Buzz" | |
default: | |
return String(number) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBOutlet weak var tableView: UITableView! { | |
didSet{ | |
tableView.delegate = self | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: [Previous](@previous) | |
import UIKit | |
import PlaygroundSupport | |
import AVFoundation | |
import AVKit | |
let frame = CGRect(x: 0, y: 0, width: 400, height: 400) | |
final class LoopedVideoPlayerView: UIView { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class LoopedVideoPlayerView: UIView { | |
fileprivate var videoURL: URL? | |
fileprivate var queuePlayer: AVQueuePlayer? | |
fileprivate var playerLayer: AVPlayerLayer? | |
fileprivate var playbackLooper: AVPlayerLooper? | |
func prepareVideo(_ videoURL: URL) { | |
let playerItem = AVPlayerItem(url: videoURL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func stripUrlToValid(_ url: String) -> String { | |
var stripped = url.trimmingCharacters(in: .whitespacesAndNewlines) | |
if stripped.hasPrefix("https") { | |
stripped = stripped.replacingOccurrences(of: "https", with: "") | |
} | |
if stripped.hasPrefix("http") { | |
stripped = stripped.replacingOccurrences(of: "http", with: "") | |
} | |
while stripped.hasPrefix(":") || stripped.hasPrefix("/") { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
do { | |
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, mode: AVAudioSessionModeDefault, options: .mixWithOthers) | |
try AVAudioSession.sharedInstance().setActive(true) | |
} catch { | |
print(error) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Fraction: ExpressibleByStringLiteral { | |
private(set) var n: Int | |
private(set) var d: Int | |
init(numerator: Int, denominator:Int) { | |
self.n = numerator | |
self.d = denominator | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fileprivate var propertyAnimator: UIViewPropertyAnimator! | |
fileprivate var blurEffectView: UIVisualEffectView! | |
fileprivate var backGradientView: UIView! | |
func addWorkoutBlur() { | |
if !UIAccessibilityIsReduceTransparencyEnabled() { | |
if blurEffectView != nil { | |
blurEffectView.removeFromSuperview() | |
} | |
if backGradientView != nil { |
OlderNewer