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 Horse { | |
var name:String? | |
var beenThroughDesert:Bool = false | |
init(){} | |
init(horsename:String?, desert:Bool) { | |
if let n = horsename { | |
name = n | |
} | |
beenThroughDesert = desert | |
} |
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 ListNode<T> { | |
var items:T[] = [] | |
var item: T { get { return items[0] } set { items = [newValue] }} | |
var nextNode:ListNode? | |
init( item i:T ) { item = i} | |
} |
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/Foundation.h> | |
typedef void(^CompletionHandler)(id connection, id result, NSError * error); | |
typedef BOOL(^Counter)(); | |
typedef void(^RequestWrapper)(CompletionHandler); | |
@interface SMRequestFoo : NSObject | |
+(void) | |
request :(id ) thing | |
completion:(CompletionHandler) completion; |
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/Foundation.h> | |
typedef void(^CompletionHandler)(id connection, id result, NSError * error); | |
typedef BOOL(^Counter)(); | |
typedef void(^RequestWrapperComp)(); | |
@interface SMRequestFoo : NSObject | |
+(void) | |
request :(id ) thing |
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
[_photo_library | |
assetForURL: url | |
resultBlock:^(ALAsset *asset) | |
{ | |
ALAssetRepresentation * rep = [asset defaultRepresentation]; | |
NSDictionary * meta = [rep metadata]; | |
if( meta[ @"AdjustmentXMP" ] ) { | |
// Image is filtered, add to list | |
} |
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
// Because [EEE, ]dd MMM yyyy HH:mm[:ss] z | |
// we can split based on , and : and count. | |
// There is probably a better way to do this | |
// without splitting the strings. | |
func dateFromPubdateString(str:String) -> NSDate? { | |
func hasDay(str:String) -> Bool { | |
return str.componentsSeparatedByString(",").count > 1 | |
} |
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 Cocoa | |
@NSApplicationMain | |
class AppDelegate: NSObject, NSApplicationDelegate { | |
@IBOutlet weak var window: NSWindow! | |
func applicationDidFinishLaunching(aNotification: NSNotification) { | |
let cp = NSColorPanel.sharedColorPanel() |
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
var bgTask:UIBackgroundTaskIdentifier! | |
bgTask = app.beginBackgroundTaskWithExpirationHandler { () -> Void in | |
self.app.endBackgroundTask(bgTask) | |
} | |
// Don't do this |
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
/* | |
In your .plist : | |
<key>UIBackgroundModes</key> | |
<array> | |
<string>location</string> | |
</array> | |
... | |
<key>UIRequiredDeviceCapabilities</key> | |
<array> | |
... |
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 | |
import AVFoundation | |
class ViewController: UIViewController, AVSpeechSynthesizerDelegate { | |
let synth = AVSpeechSynthesizer() | |
let avsesh = AVAudioSession.sharedInstance() | |
let voice = AVSpeechSynthesisVoice(language: "en-GB") | |
let avopts:AVAudioSessionCategoryOptions = [ | |
.MixWithOthers, | |
.DuckOthers, |
OlderNewer