Last active
September 2, 2015 15:16
-
-
Save mayoralito/8cdb5bee61093b6b2591 to your computer and use it in GitHub Desktop.
fuckingblocksyntax.com using Swift
This file contains hidden or 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
// As a local variable: | |
// Objective C - http://fuckingblocksyntax.com/ | |
returnType (^blockName)(parameterTypes) = ^returnType(parameters) {...}; | |
As a property: | |
// Swift - | |
// Objective C - http://fuckingblocksyntax.com/ | |
@property (nonatomic, copy) returnType (^blockName)(parameterTypes); | |
As a method parameter: | |
// Swift - | |
// Objective C - http://fuckingblocksyntax.com/ | |
- (void)someMethodThatTakesABlock:(returnType (^)(parameterTypes))blockName; | |
As an argument to a method call: | |
// Swift - | |
// Objective C - http://fuckingblocksyntax.com/ | |
[someObject someMethodThatTakesABlock:^returnType (parameters) {...}]; | |
// Swift - | |
//As a typedef: | |
// Objective C - http://fuckingblocksyntax.com/ | |
typedef returnType (^TypeName)(parameterTypes); | |
TypeName blockName = ^returnType(parameters) {...}; | |
// Swift - | |
//[typealias blockName paramas -> return type ] | |
typealias MyCustomName = (param1: NSString, param2:NSString) -> Void | |
typealias CompletionBlock = ( param1 : NSString, param1 : Int) -> () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment