This file contains hidden or 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
| // String to Data utf8 | |
| let strData: Data = Data("String".utf8) | |
| // Data to String | |
| let str = String(data: strData, encoding: .utf8) |
This file contains hidden or 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
| // | |
| // RxAVSpeechSynthesizerDelegate.swift | |
| // Pomodoro | |
| // | |
| // Created by Won on 17/12/2018. | |
| // Copyright © 2018 won. All rights reserved. | |
| // | |
| #if os(iOS) |
This file contains hidden or 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
| // | |
| // ViewController.swift | |
| // Playback | |
| // | |
| // Created by kyle.jo on 12/12/2018. | |
| // Copyright © 2018 kyle.jo. All rights reserved. | |
| // | |
| import AVFoundation | |
| import UIKit |
This file contains hidden or 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
| xcrun simctl io booted screenshot 1r.png | |
| xcrun simctl io booted recordVideo apppreview.mp4 | |
| ctrl + c # to stop | |
| # https://shashikantjagtap.net/simctl-control-ios-simulators-command-line/ |
This file contains hidden or 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
| UIView.transition(with: self.backgroundImageView, | |
| duration: 0.7, | |
| options: [.transitionCrossDissolve], | |
| animations: { self.backgroundImageView.image = toImageA }, | |
| completion: { _ in swap(&toImageA, &toImageB) }) | |
| } |
This file contains hidden or 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 isAlpha(char: Character) -> Bool { | |
| switch char { | |
| case "a"..."z": | |
| return true | |
| case "A"..."Z": | |
| return true | |
| default: | |
| return false | |
| } | |
| } |
This file contains hidden or 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 rowAndCol(s: Int, N: Int) -> (Int, Int) { | |
| var s = s - 1 | |
| var row = N - (s / N) - 1 | |
| var col = row % 2 != N % 2 ? s % N : N - 1 - (s % N) | |
| return (row, col) | |
| } | |
| let range = 0..<N | |
| for row in range.reversed() { | |
| let reversed: [Int] = range.reversed() |
This file contains hidden or 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
| print("Swift is awesome ;;") | |
| print("Swift", "is", "awesome", separator:" ") | |
| print("Swift", "is", "awesome", separator:" ", terminator:".") | |
| // Console | |
| // Swift is awesome ;; | |
| // Swift is awesome | |
| // Swift is awesome. |
This file contains hidden or 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
| import Foundation | |
| // MARK: Creating Array | |
| var someInts = [Int]() | |
| print("someInts is of type [Int] with \(someInts.count) items.") | |
| // Prints "someInts is of type [Int] with 0 items." | |
| someInts.append(3) | |
| // someInts now contains 1 value of type Int |
This file contains hidden or 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
| - (void)setupCaptureSession | |
| { | |
| NSError *error = nil; | |
| AVCaptureSession *session = [[AVCaptureSession alloc] init]; | |
| session.sessionPreset = AVCaptureSessionPresetMedium; | |
| AVCaptureDevice *device = [AVCaptureDevice | |
| defaultDeviceWithMediaType:AVMediaTypeVideo]; |