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
//: Playground - noun: a place where people can play | |
//To try out this code, copy and paste into a new Xcode playground. | |
import UIKit | |
class Operation: NSObject | |
{ | |
let nextOperation: Operation? | |
init(next: Operation? = 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
//: Playground - noun: a place where people can play | |
import UIKit | |
public protocol Maths | |
{ | |
func doMath(left: Double, right: Double) -> Double | |
} | |
class Addition: NSObject, Maths |
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
// | |
// ViewController.swift | |
// BehaviorsDemo | |
// | |
// Created by Saul Mora on 8/25/16. | |
// Copyright © 2016 Magical Panda. 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
protocol Thing { | |
var name: String { get } | |
} | |
protocol UsingThing { | |
func doSomething(with: Thing) | |
} | |
struct Test: UsingThing { |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
protocol DataSource { | |
func fetchValue() -> String? | |
} | |
protocol DataSourceCacheStrategy { | |
func retrieve<T>(from: [DataSource], using: DataSource -> T?) -> T? |
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 | |
class Testing : NSObject | |
{ | |
private func privateWork() { | |
} | |
internal func internalWork(){ | |
} | |
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
#!/bin/sh | |
## $1 is the path to the model relative to the project dir | |
## $2 is the name of the model file | |
##TODO, make the path optional and the model file required | |
mogen=`which mogenerator` | |
PlistBuddy=`which PlistBuddy` | |
if [[ -x $1 ]]; then |
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
class CustomObject : NSManagedObject | |
{ | |
init(inContext context:NSManagedObjectContext = SingletonContextStorage.context) | |
{ | |
let klass = CustomObject.self | |
let entity = NSEntityDescription.entityForName(klass.entityName(), inManagedObjectContext: context) | |
super.init(entity: entity, insertIntoManagedObjectContext: context) | |
} | |
} |
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 | |
{ | |
func writeTo(outputStream:NSOutputStream) | |
{ | |
if let data = self.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) | |
{ | |
let bytes = ConstUnsafePointer<UInt8>(data.bytes) | |
outputStream.write(bytes, maxLength: data.length) | |
} | |
} |
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
@implementation NSNumber (PandaHelpers) | |
- (void) mgp_times:(void(^)(NSInteger))thingToDo; | |
{ | |
NSAssert(thingToDo, @"No operation to perform"); | |
for (NSInteger i = 0; i < [self integerValue]; i++) | |
{ | |
thingToDo(i); | |
} |
NewerOlder