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
/* | |
* syscon - A tool for reading the system console from an iOS device | |
* via USB and displaying it in the OS X terminal in "real time". | |
* | |
* This tool and its source code is hereby released into the public domain. | |
* No warranty given, no responsibility taken. Use at your own risk. | |
* | |
* How to build: | |
* | |
* clang -o syscon -framework CoreFoundation -framework MobileDevice |
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
#!/usr/bin/xcrun swift | |
println("Hello, World!") |
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
operator infix <- {} | |
infix func <- <T>(inout left: T, right: T) { | |
left = right | |
} | |
var value = 0 // Initialize | |
value <- 1337 | |
// value now contains 1337 |
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
operator postfix ** {} | |
postfix func ** (value: Int) -> Int { | |
return value * value | |
} | |
let a = 3** + 1 | |
// a now contains 10 |
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
operator infix <=> {} | |
infix func <=> <T>(inout left: T, inout right: T) { | |
let tmp = left | |
left = right | |
right = tmp | |
} | |
var a = 1337 | |
var b = 4711 |
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
let values = [4, 8, 15, 16, 23, 42] | |
let meanValue = values.reduce(0, +) / values.count | |
// + is a operator function and we can pass it in to reduce as the function parameter. |
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
let values: [UInt] = [4, 8, 15, 16, 23, 42] | |
let biggestValue = values.reduce(0, {$1 > $0 ? $1 : $0}) | |
// biggestValue is now 42 |
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
enum Faction { | |
case empire | |
case rebels | |
} | |
let characters: [(name: String, faction: Faction, episodes: [Int])] = [ | |
(name: "Darth Maul", faction: .empire, episodes: [1]), | |
(name: "Han Solo", faction: .rebels, episodes: [4, 5, 6]), | |
(name: "Palpatine", faction: .empire, episodes: [1, 2, 3, 5, 6]), | |
(name: "R2-D2", faction: .rebels, episodes: [1, 2, 3, 4, 5, 6]), |
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/UIKit.h> | |
// IB_DESIGNABLE means that the view will be | |
// rendered live in Interface Builder. | |
IB_DESIGNABLE | |
@interface MJPlaceholderView : UIView | |
// IBInspectable means that the property |
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
let numberStrings = (1...10).map(String.init) |
OlderNewer