Last active
August 29, 2015 14:07
-
-
Save isthisjoe/b3112e6ce267d9fa06ab to your computer and use it in GitHub Desktop.
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
:: Swift iOS Version Checking :: | |
let iOS7 = floor(NSFoundationVersionNumber) <= floor(NSFoundationVersionNumber_iOS_7_1) | |
let iOS8 = floor(NSFoundationVersionNumber) > floor(NSFoundationVersionNumber_iOS_7_1) | |
:: Replace Magic Strings with Enumerations in Swift :: | |
enum SegueIdentifier: String { | |
case OtherScreenSegue1 = "otherScreenSegue1" | |
case OtherScreenSegue2 = "otherScreenSegue2" | |
case OtherScreenSegue3 = "otherScreenSegue3" | |
} | |
override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) { | |
if let identifier = SegueIdentifier.fromRaw(segue.identifier) { | |
switch identifier { | |
case .OtherScreenSegue1: | |
println("Going to other screen 1") | |
.. | |
default: | |
println("Going somewhere else") | |
} | |
} | |
} | |
:: Print obj Type :: | |
let typeLongName = _stdlib_getDemangledTypeName(obj) | |
let tokens = split(typeLongName, { $0 == "." }) | |
if let typeName = tokens.last { | |
println("Variable \(obj) is of Type \(typeName).") | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment