See this SO discussion.
- https://github.com/simonwhitaker/swmath — define new functions which utilize clang function overloading
import sys; reload(sys); sys.setdefaultencoding('utf-8') | |
import sqlite3 | |
import urllib2 | |
import urllib | |
import simplejson | |
login = 'your github id' | |
token = 'your github api key' | |
repo = 'username/reponame' |
// Playground - noun: a place where people can play | |
import UIKit | |
var str = "Hello, playground" | |
enum TimeIntervalUnit { | |
case Seconds, Minutes, Hours, Days, Months, Years | |
func dateComponents(interval: Int) -> NSDateComponents { |
See this SO discussion.
#define COMPARE(A, B) ({ \ | |
__typeof__(A) __a = (A); \ | |
__typeof__(B) __b = (B); \ | |
__a < __b ? NSOrderedAscending : __a == __b ? NSOrderedSame : NSOrderedDescending; \ | |
}) |
var Dictionary; | |
if (!Dictionary) { | |
Dictionary = {}; | |
} | |
(function () { | |
'use strict'; | |
function f(n) { | |
// Format integers to have at least two digits. |
return
keyword. Don't add semicolons except where syntactically demanded in statements or to separate statements on the same line.var
when let
is appropriate, especially for properties. The compiler better optimizes let
statements for items whose values will not change during their lifetime. For example, Apple writes, "It is good practice to create immutable collections in all cases where the collection does not need to change. Doing so enables the Swift compiler to optimize the performance of the collections you create."// | |
// MultiDirectionAdjudicatingScrollView.swift | |
// Khan Academy | |
// | |
// Created by Andy Matuschak on 12/16/14. | |
// Copyright (c) 2014 Khan Academy. All rights reserved. | |
// | |
import UIKit | |
import UIKit.UIGestureRecognizerSubclass |
// @discardableResult to be added | |
// @noescape needs to move to type annotation | |
// needs to add _ for item | |
public func with<T>(item: T, @noescape update: (inout T) throws -> Void) rethrows -> T { | |
var this = item; try update(&this); return this | |
} |
// | |
// Perlin noise text displacement. | |
// Created using Processing 3.5.3. | |
// | |
// Code by @marcedwards from @bjango. | |
// | |
PGraphics textbuffer; | |
void setup() { |
"JUST BECAUSE YOU'RE USING SWIFT DOESN'T MEAN YOUR QUESTION IS ABOUT SWIFT"
Ask your question and then be patient. Tell us what you want to happen, what is actually happening, and include any error messages you find: