Skip to content

Instantly share code, notes, and snippets.

View Ivorforce's full-sized avatar
👽
Working from Mars

Lukas Tenbrink Ivorforce

👽
Working from Mars
View GitHub Profile
@smileyborg
smileyborg / SimulatedSlowLoadingImage.swift
Created August 5, 2017 02:06
Snippet showing how to create an NSItemProvider with a simulated delay for loading an image
import UIKit
import MobileCoreServices
let image = UIImage() // your actual image
let itemProvider = NSItemProvider()
itemProvider.registerDataRepresentation(forTypeIdentifier: kUTTypeJPEG as String, visibility: .all) { (completionBlock) -> Progress? in
let unitsOfWork = 10 + Int64(arc4random_uniform(UInt32(10))) // 10 - 19 units
let progress = Progress.discreteProgress(totalUnitCount: unitsOfWork)