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
switch (originalOrientation) | |
{ | |
case UIImageOrientationUp: | |
orientationValue = @1; | |
break; | |
case UIImageOrientationDown: | |
orientationValue = @3; | |
break; | |
case UIImageOrientationLeft: | |
orientationValue = @8; |
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
-(void)removeDataStoreAtURL:(NSURL*)url | |
{ | |
// Need to remove anything matching the first part - there are also logging files alongside the SQLite file itself. | |
// Typical directory contents are: | |
// Name.sqlite, Name.sqlite-shm, Name.sqlite-wal | |
NSURL *folderURL = [url URLByDeletingLastPathComponent]; | |
NSArray *contents = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:folderURL includingPropertiesForKeys:nil options:0 error: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
import Foundation | |
func coalesce<T>(args: T?...) -> T? { | |
for possible in args { | |
if let actual = possible { | |
return actual | |
} | |
} | |
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
import UIKit | |
// Snapshot utilities | |
extension UIView { | |
func snapshotView(view: UIView, afterUpdates: Bool) -> UIView { | |
let snapshot = view.snapshotViewAfterScreenUpdates(afterUpdates) | |
self.addSubview(snapshot) | |
snapshot.frame = convertRect(view.bounds, fromView: view) | |
return snapshot |
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 renderer = UIGraphicsImageRenderer(size: CGSize(width: 400, height: 400)) | |
let image = renderer.image { | |
context in | |
UIColor.lightGray.setFill() | |
UIRectFill(context.format.bounds) | |
UIColor.black.set() | |
UIRectFrame(context.format.bounds) | |
let text = "TEST IMAGE \n\(Date())" as NSString | |
let paragraph = NSMutableParagraphStyle() | |
paragraph.alignment = .center |
OlderNewer