-
-
Save u10int/23d66c9235de922c83d4 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
extension Array { | |
func first() -> Element? { | |
if isEmpty { | |
return nil | |
} | |
return self[0] | |
} | |
func last() -> Element? { | |
if isEmpty { | |
return nil | |
} | |
let index = count - 1 | |
return self[index] | |
} | |
} |
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 offset = 2.0 | |
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(offset * Double(NSEC_PER_SEC))), dispatch_get_main_queue(), { | |
// Do something | |
}) |
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 func sharedClient() -> CanaryClient { | |
struct Static { | |
static var instance: CanaryClient? | |
static var token: dispatch_once_t = 0 | |
} | |
dispatch_once(&Static.token, { | |
Static.instance = CanaryClient() | |
}) | |
return Static.instance! | |
} |
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
// You can make aliases for closure types | |
typealias AccountStoreMultipleAccountsCompletion = (ACAccount[]?, NSError?) -> () | |
typealias AccountStoreSingleAccountCompletion = (ACAccount?, NSError?) -> () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment