Skip to content

Instantly share code, notes, and snippets.

@loganwright
loganwright / ImageManager.swift
Created October 20, 2015 14:20
Image Manager
private let ImageFolderDirectoryName = "SomeAppDomainImageDirectory"
final class ImageManager: NSObject {
// MARK: Singleton
class func sharedManager() -> ImageManager {
struct Singleton {
static let instance = ImageManager()
}
@loganwright
loganwright / SubmissionChecklist.md
Created October 20, 2015 19:34
Submission Checklist

Client

  • App Icon
  • Screenshots
  • Decriptions
  • Tags (< 1000 characters)
  • Setup Apple Developer Account
  • Grant Access to Developers

Dev

@loganwright
loganwright / xcodebuild.md
Created October 21, 2015 01:23
Xcode build lines

Some commands I'm using from xcodebuild for possible future reference. If you don't know what you're doing, this probably isn't a good place to be because I don't either!

xcodebuild -scheme "Bose Connect" -workspace Monet.xcworkspace -configuration Debug clean build test -destination platform='iOS Simulator',name='iPhone 6'

@loganwright
loganwright / PrioritySort.swift
Created October 22, 2015 20:16
Sort Priorities in Swift
enum SortOrder {
case Ascending, Descending, Same
}
extension Array {
typealias Sorter = (Element, Element) -> SortOrder
func sortWithPriorities(sorters: Sorter...) -> Array {
return sort { (left, right) -> Bool in
for sorter in sorters {
switch sorter(left, right) {
@loganwright
loganwright / ColorDescriptor.swift
Created October 25, 2015 05:21
Color Descriptor
enum ColorDescriptor {
case PatternImage(imageName: String)
case RGB(r: Int, g: Int, b: Int, a: Int)
}
extension ColorDescriptor : StringLiteralConvertible, RawRepresentable, Equatable {
typealias RawValue = StringLiteralType
typealias ExtendedGraphemeClusterLiteralType = StringLiteralType
typealias UnicodeScalarLiteralType = StringLiteralType
@loganwright
loganwright / SoundFile.swift
Created October 25, 2015 05:23
Sound File
import AVFoundation
protocol SoundFile {
var soundFile: String { get }
}
extension SoundFile {
private var nameComponents: [String] {
return soundFile.componentsSeparatedByString(".")
@loganwright
loganwright / UIView+Nib.swift
Created October 25, 2015 05:34
UIView+Nibs Swift
extension UIView {
class func fromNib(nibNameOrNil: String? = nil) -> Self {
return fromNib(nibNameOrNil, type: self)
}
class func fromNib<T : UIView>(nibNameOrNil: String? = nil, type: T.Type) -> T {
let v: T? = fromNib(nibNameOrNil)
return v!
}
@loganwright
loganwright / CellConfiguring.swift
Last active November 7, 2015 15:26
Cell Configuring
extension UITableView {
func registerCell<T : UITableViewCell>(_: T.Type, identifier: String = T.identifier) {
if let nib = T.nib {
registerNib(nib, forCellReuseIdentifier: identifier)
} else {
registerClass(T.self, forCellReuseIdentifier: identifier)
}
}
func registerHeader<T: UITableViewHeaderFooterView>(_: T.Type, identifier: String = T.identifier) {
@loganwright
loganwright / Bag.swift
Last active January 28, 2016 16:45
Bag
internal extension SequenceType {
func ip_splitFilter(@noescape filter: (Generator.Element) throws -> Bool) rethrows -> (passed: [Generator.Element], failed: [Generator.Element]) {
var passed: [Generator.Element] = []
var failed: [Generator.Element] = []
try forEach {
if try filter($0) {
passed.append($0)
} else {
failed.append($0)
}
@loganwright
loganwright / GestureRecognizerDelegateMulticast.swift
Last active February 1, 2016 20:03
GestureMulticast in case you might need it
public struct Weak<T where T : AnyObject> {
public weak var value: T?
public init(_ value: T) {
self.value = value
}
}
public protocol Multicast : class {
typealias Delegate: AnyObject
var delegateReferences: [Weak<Delegate>] { get set }