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 Foundation | |
import Photos | |
func saveToPhotoLibrary(url: URL) { | |
PHPhotoLibrary.requestAuthorization { status in | |
if status == .authorized { | |
PHPhotoLibrary.shared().performChanges( | |
{ | |
let options = PHAssetResourceCreationOptions() | |
options.shouldMoveFile = false |
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
extension UserDefaults { | |
/// get a default value from Settings.bundle, and set it to UserDefaults. | |
/// return the value. | |
static func defaultValue(forKey key: String) -> Any? { | |
guard let path = Bundle.main.path(forResource: "Root", ofType: "plist", inDirectory: "Settings.bundle") else { | |
return nil | |
} | |
guard let settings = NSDictionary(contentsOfFile: path) else { | |
return nil |
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
extension String { | |
/// URLエンコードした文字列を返す。 | |
/// [参考] https://dev.classmethod.jp/smartphone/iphone/urlencode-spec-and-implementation-for-swift/ | |
var urlEncoded: String { | |
// 半角英数字 + "/?-._~" のキャラクタセットを定義 | |
let charset = CharacterSet.alphanumerics.union(.init(charactersIn: "/?-._~")) | |
// 一度すべてのパーセントエンコードを除去(URLデコード) | |
let removed = removingPercentEncoding ?? 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
// | |
// FullContainerViewController.swift | |
// ContainerSample | |
// | |
// Created by fhisa on 2017/04/19. | |
// Copyright © 2017年 KuronucoKoubou. All rights reserved. | |
// | |
import UIKit |
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
// | |
// RoundFrameView.swift | |
// Rescube | |
// | |
// Created by fhisa on 2016/03/23. | |
// Copyright (c) 2016 Hisakuni Fujimoto. All rights reserved. | |
// | |
import UIKit |
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 Foundation | |
public extension NSLocale { | |
class func mono_currentLocale() -> NSLocale { | |
return NSLocale(localeIdentifier: "ja_JP") | |
} | |
} | |
public func setupJapaneseLocale() { | |
let old_method = class_getClassMethod(NSLocale.self, "currentLocale") |