Skip to content

Instantly share code, notes, and snippets.

View ocollet's full-sized avatar

Olivier Collet ocollet

View GitHub Profile
//
// EventHandler.swift
// Unsplash
//
// Created by Olivier Collet on 2018-05-04.
// Copyright © 2018 Unsplash. All rights reserved.
//
import UIKit
@ocollet
ocollet / delegate.swift
Created November 27, 2018 13:07
UnsplashPhotoPicker Delegate
func unsplashPhotoPicker(_ photoPicker: UnsplashPhotoPicker, didSelectPhotos photos: [UnsplashPhoto]) {
// Do something with the photos
}
@ocollet
ocollet / configuration.swift
Created November 27, 2018 13:06
UnsplashPhotoPicker Configuration
let configuration = UnsplashPhotoPickerConfiguration(
accessKey: "<UNSPLASH_API_ACCESS_KEY>",
secretKey: "<UNSPLASH_API_SECRET_KEY>"
)
let photoPicker = UnsplashPhotoPicker(configuration: configuration)
photoPicker.photoPickerDelegate = self
present(photoPicker, animated: true, completion: nil)
struct StoryboardIdentifier {
static let template = "Template"
}
struct ViewControllerIdentifier {
static let grid = "Grid"
static let gridNavigation = "GridNavigation"
static let item = "Item"
static let list = "List"
static let listNavigation = "ListNavigation"
@ocollet
ocollet / onboarding.swift
Created May 10, 2018 11:59
On-demand resources
private lazy var bundleResourceRequest = NSBundleResourceRequest(tags: Set(["Onboarding"]))
private func loadOnDemandAssets() {
bundleResourceRequest.conditionallyBeginAccessingResources { [unowned self] (available) in
if available {
self.loadOnboardingAssets()
} else {
self.bundleResourceRequest.beginAccessingResources { (error) in
guard error == nil else { return }
self.loadOnboardingAssets()
@ocollet
ocollet / Configuration.swift
Last active February 20, 2018 03:54
Configuration with Swift struct
// Declaration
struct ApplicationConfiguration {
let slideshowTimeInterval: TimeInterval = 15
}
struct UnsplashConfiguration {
let applicationId = "********"
let secret = "********"
let apiURL = "https://api.unsplash.com/"
@ocollet
ocollet / NSDate+TimeIntervalAddition.h
Created February 29, 2012 06:06
NSDate - TimeIntervalInWords
@interface NSDate (TimeIntervalAddition)
- (NSString *)timeIntervalInWords;
@end