Skip to content

Instantly share code, notes, and snippets.

import Foundation
public protocol ComputedPropertyProvider {
var computedProperty:String { get}
}
public extension ComputedPropertyProvider {
var computedProperty: String {
return "this is computed property"
}
firstLabel.topAnchor.constraintEqualToAnchor(self.view.topAnchor constant: 20).active = true
secondLabel.topAnchor.constraintEqualToAnchor(firstLabel.topAnchor).active = true
import UIKit
func addViewAndButton() {
// iOS 9 availability coolness
guard #available(iOS 9, *) else {
return
}
// boilerplate view creation
//: Playground - noun: a place where people can play
import UIKit
let scaleValues = ["10 feet", "100 feet", "100 yards", "400 yards", "800 yard", "1200 yards", "1 mile"]
var scaleLabels = [UILabel]()
for index in 0..<scaleValues.count {
var label = UILabel(frame: CGRectMake((CGFloat(index) + 1 * 100), 10, 100, 25))
@adajos
adajos / SwiftEnumerate.swift
Last active August 29, 2015 14:24
Swift's Enumerate Awesomeness
//: Playground - noun: a place where people can play
import UIKit
let scaleValues = ["10 feet", "100 feet", "100 yards", "400 yards", "800 yard", "1200 yards", "1 mile"]
var scaleLabels = [UILabel]()
for (scaleValueIndex, scaleValue) in scaleValues.enumerate() {
var label = UILabel(frame: CGRectMake((CGFloat(scaleValueIndex) + 1 * 100), 10, 100, 25))