Skip to content

Instantly share code, notes, and snippets.

View Nub's full-sized avatar
🕶️

Zach Thayer Nub

🕶️
View GitHub Profile
//
// NSURL_Networking.swift
// swiftTools
//
// Created by Zachry Thayer on 6/3/14.
// Copyright (c) 2014 Zachry Thayer. All rights reserved.
//
import Foundation
func fetch(method: String, body: (NSString, NSData)!, completion: (NSData -> Void)) {
let request = self.request()
request.HTTPMethod = method
if body != nil {
let mime = body.0
let data = body.1
request.setValue(mime, forHTTPHeaderField: Networking.mimeHTTPHeaderField)
request.HTTPBody = data;
}
//
// NSURL_Networking.swift
// swiftTools
//
// Created by Zachry Thayer on 6/3/14.
// Copyright (c) 2014 Zachry Thayer. All rights reserved.
//
import Foundation
//
// NSURL_Networking.swift
// swiftTools
//
// Created by Zachry Thayer on 6/3/14.
// Copyright (c) 2014 Zachry Thayer. All rights reserved.
//
import Foundation
// Playground - noun: a place where people can play
import Cocoa
func foo(done: ((String) -> Void), bar: String = "default"){
done(bar)
}
// It works!, but what if I want to set bar?
foo(){(bar: String) in
// Playground - noun: a place where people can play
import Cocoa
func instanceOfClass<T>(aClass: T.Type) -> AnyObject {
return aClass()
}
var a = instanceOfClass(String)
// The following code only needs to be called once, and only requires to be called before user input is expected
// It performs some very basic logic to handle search queries
RACSignal* searchTextChanged = [self rac_signalForSelector:@selector(searchBar:textDidChange:)
fromProtocol:@protocol(UISearchBarDelegate)];
__block NSInteger minimumSearchLength = 3;
[[[[searchTextChanged
map:^id(RACTuple *tuple) {
Welcome to Swift! Type :help for assistance.
1> let a = -3
la: Int = -3
2> let b = a.asUnsigned()
b: UInt = {
value = -3
}
3> println(b)
18446744073709551613
4> println(a)
7> let d = ["test":("a","b")]
d: Dictionary<String, (String, String)> = {
[0] = {
key = "test"
value = {
0 = "a"
1 = "b"
}
}
}
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x178095270 H:|-(0)-[PagedScrollView:0x147e31190] (Names: '|':UIView:0x1701868d0 )>",
"<NSLayoutConstraint:0x1780952c0 H:[PagedScrollView:0x147e31190]-(0)-| (Names: '|':UIView:0x1701868d0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x178098c40 h=--& v=--& H:[UIView:0x1701864c0(320)]>",
"<NSLayoutConstraint:0x17009e3c0 camImage.height == 0.5625*UIView:0x170187f90.width - 180 (Names: camImage:0x147d0d390 )>",
"<NSLayoutConstraint:0x178c8cd00 UIView:0x170187f90.width == VerticalFlowLayout:0x147e7