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
// UIImage+Downsample.swift | |
// Created by Todd Hopkinson | |
import UIKit | |
extension UIImage { | |
func downsample(reductionAmount: Float) -> UIImage? { | |
let image = UIKit.CIImage(image: 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
let birthday = Todd.birthday // gets my birthday | |
let now = NSDate() | |
let secondsDifference = now.timeIntervalSinceDate(birthday) | |
let secondsPerDay = 60*60*24 // 60 seconds * 60 minutes * 24 hours | |
let daysSinceBirthday = secondsDifference / secondsPerDay |
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
// get an objects type | |
lldb: po type(of: yourObject) | |
// info dump on an object | |
lldb: po dump(youObject) |
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
source 'https://github.com/CocoaPods/Specs.git' | |
platform :ios, '9.0' | |
use_frameworks! | |
target 'lavaApp' do | |
pod 'ARSLineProgress', '~> 2.0' | |
pod 'Alamofire', '~> 4.0' | |
pod 'Willow', '~> 2.0' | |
pod 'SwiftyJSON', '~> 3.1.1' |
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
enum LavaError: Error { | |
case LavaNotHotError | |
case LavaTooHotError | |
} | |
struct LavaSpecialResponseCode: Error { | |
enum ErrorKind: Int { | |
case missingParams | |
case badData | |
} |
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 lavaButton: UIButton! { | |
didSet { | |
lavaButton.tintColor = UIColor.lavaColor() | |
} | |
} | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
} |
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
// NOTE: important to be aware that your reporting that your async is on is not on main thread | |
// see also https://developer.apple.com/library/content/samplecode/avexporter/Listings/Swift_AVFoundationExporter_main_swift.html | |
// An Interested party such as a UIViewController (the call site of embedWatermark, for example) can register as delegate | |
// and update progress indicators (like a UIProgressView or UILabel). | |
protocol VideoProcessingProgressDelegate { | |
func watermarkProgressUpdated(progress: Float) | |
} | |
class VideoProcessingProgressExample { |
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
// You have a very very large video file you need to upload to a server while your app is backgrounded. | |
// Solve by using URLSession background functionality. I will here use Alamofire to enable multipart upload. | |
class Networking { | |
static let sharedInstance = Networking() | |
public var sessionManager: Alamofire.SessionManager // most of your web service clients will call through sessionManager | |
public var backgroundSessionManager: Alamofire.SessionManager // your web services you intend to keep running when the system backgrounds your app will use this | |
private init() { | |
self.sessionManager = Alamofire.SessionManager(configuration: URLSessionConfiguration.default) | |
self.backgroundSessionManager = Alamofire.SessionManager(configuration: URLSessionConfiguration.background(withIdentifier: "com.lava.app.backgroundtransfer")) |
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
import UIKit | |
import MapKit | |
class MapViewController: UIViewController, CLLocationManagerDelegate { | |
@IBOutlet weak var mapView: MKMapView! | |
/// Location manager used to start and stop updating location. | |
let manager = CLLocationManager() | |
var receivedLocationCount = 0 |
OlderNewer