Last active
December 29, 2015 16:09
-
-
Save nverinaud/7695369 to your computer and use it in GitHub Desktop.
C# way of doing ObjC blocks.
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
/* Declaration */ | |
// In ObjC | |
typedef void (^onCompletion)(bool completed); | |
// In C# | |
public delegate void OnCompletion(bool completed); | |
/* Implementation */ | |
// In ObjC | |
- (void)myAsyncMethod:(onCompletion)completion | |
{ | |
// blablabla... | |
completion(YES); | |
} | |
// In C# | |
public void MyAsyncMethod(OnCompletion completion) | |
{ | |
// blablabla... | |
completion(true); | |
} | |
/* Usage */ | |
// ObjC | |
[obj myAsyncMethod:^(completed) { | |
// finish ! | |
}]; | |
// C# | |
obj.MyAsyncMethod((completed) => { | |
// finish ! | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment