Skip to content

Instantly share code, notes, and snippets.

@IBDesignable
public class StatefulConstraint: NSLayoutConstraint {
// MARK: Properties
@IBInspectable var state: String = ""
}
import UIKit
public protocol ConstraintStateMachineType: class {
// MARK: Types
typealias State: RawRepresentable
// MARK: Properties
var state: State? { get set }
var allConstraints: [NSLayoutConstraint] { get }
print("\(myVar)") // Optional
if let myVar = myVar {
print("\(myVar)") // Not optional
}
@pcperini
pcperini / LayoutConstraint.swift
Created December 11, 2015 00:20
don't try this at home, kids
//
// LayoutConstraint.swift
// LayoutConstraints
//
// Created by PATRICK PERINI on 12/10/15.
// Copyright © 2015 atomic. All rights reserved.
//
import UIKit
spec.source = { :git => 'https://github.com/TheAppCookbook/templates.git', :branch => 'master' }
spec.source_files = 'templates/ACBInfoPanel/ACBInfoPanelViewController.swift', 'templates/ACBInfoPanel/NSURL+ACBUrls.swift'
@pcperini
pcperini / gist:65702d56bc79e26600fd
Created July 14, 2015 16:48
internet_barometer

should i go online today? no

inhibit_all_warnings!
#use_frameworks! ## DO NOT USE --> seems to break things?
target 'PROJ' do
platform :ios, '9.0'
pod 'Realm'
end
target 'PROJ WatchKit Extension' do
*** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0x1a9923c0> was mutated while being enumerated.'
* thread #1: tid = 0x1f9c, 0x383bfc64 libobjc.A.dylib`objc_exception_throw, name = 'main', queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x383bfc64 libobjc.A.dylib`objc_exception_throw
frame #1: 0x2acd28c0 CoreFoundation`__NSFastEnumerationMutationHandler + 128
frame #2: 0x2c3baaf0 MapKit`-[MKNewAnnotationContainerView _updateAnnotationViewPositions] + 136
frame #3: 0x2c3baa42 MapKit`-[MKNewAnnotationContainerView _updateAnnotationViewPerspective] + 26
frame #4: 0x2c3d3632 MapKit`-[MKMapView _updateScrollContainerView:] + 1850
frame #5: 0x2c3ed78c MapKit`-[MKMapView mapLayerDidDraw:] + 72
frame #6: 0x35a3e218 VectorKit`-[GGLLayer drawWithTimestamp:] + 456
// MARK: JSON Valid Types
protocol JSON {}
// MARK: - Type Aliases
typealias JSONDictionary = Dictionary<String, JSON>
typealias JSONArray = Array<JSON>
// MARK: - Primitives
extension Bool: JSON {}
extension Int: JSON {}
class MyClass: NSObject {
enum Notification: String {
case AnEventHappened = "AnEventHappened"
}
}
// just sayin