Skip to content

Instantly share code, notes, and snippets.

//
// CameraController.swift
//
import AVFoundation
import Photos
import UIKit
class CameraController: UIViewController {
enum Camera {
@ntamvl
ntamvl / cant-install-rmagick-2-13-1-cant-find-magickwand-h.md
Last active February 21, 2024 11:13
[Resolved In Mac OSX Sierra] Can't install RMagick 2.13.1. Can't find MagickWand.h.

[Resolved] Can't install RMagick 2.13.1. Can't find MagickWand.h

In Mac OSX Sierra, to solve the issue, I had to do the following:

Clean:

brew uninstall imagemagick
brew unlink imagemagick

Then install:

extension PHPhotoLibrary {
typealias PhotoAsset = PHAsset
typealias PhotoAlbum = PHAssetCollection
static func saveImage(image: UIImage, albumName: String, completion: (PHAsset?)->()) {
if let album = self.findAlbum(albumName) {
saveImage(image, album: album, completion: completion)
return
}
@nicklockwood
nicklockwood / Deprecated.md
Last active March 28, 2022 08:16
Writing Objective-C framework code that works on multiple OS versions AND can be compiled using multiple SDK versions without warnings can be a PITA. Here's my approach:

Suppose we want to add support for a new iOS 8 API in our framework that replaces an older iOS 7 API. There are a few problems we might face:

  1. The new API will crash if we call it on iOS 7
  2. The new API won't compile if we build it using the iOS 7 SDK
  3. The old API will raise a deprecation warning if built with a deployment target of iOS 8 and up

These three problems require three different technical solutions:

  1. We can avoid calling the new API on an old OS version by using runtime detection (e.g. respondsToSelector:)
  2. We can avoid compiling new APIs on old SDKs using the __IPHONE_OS_VERSION_MAX_ALLOWED macro