How Do I Declare A Block in Objective-C? [备忘]
来源:互联网 发布:热传导 软件 编辑:程序博客网 时间:2024/06/10 11:15
How Do I Declare A Block in Objective-C?
As a local variable:
returnType (^blockName)(parameterTypes) = ^returnType(parameters) {...};
As a property:
@property (nonatomic, copy) returnType (^blockName)(parameterTypes);
As a method parameter:
- (void)someMethodThatTakesABlock:(returnType (^)(parameterTypes))blockName;
As an argument to a method call:
[someObject someMethodThatTakesABlock:^returnType (parameters) {...}];
As a typedef:
typedef returnType (^TypeName)(parameterTypes);
TypeName blockName = ^returnType(parameters) {...};
This site is not intended to be an exhaustive list of all possible uses of blocks.
If you find yourself needing syntax not listed here, it is likely that a typedef would make your code more readable.
Unable to access this site due to the profanity in the URL? http://goshdarnblocksyntax.com is a more work-friendly mirror.
转自:http://fuckingblocksyntax.com/
If you find yourself needing syntax not listed here, it is likely that a typedef would make your code more readable.
Unable to access this site due to the profanity in the URL? http://goshdarnblocksyntax.com is a more work-friendly mirror.
转自:http://fuckingblocksyntax.com/
2 0
- How Do I Declare A Block in Objective-C? [备忘]
- How Do I Declare A Block in Objective-C?
- How Do I Declare A Block in Objective-C?
- How Do I Declare A Block in Objective-C?
- How Do I Declare a Closure in Swift?
- How do I create delegates in Objective-C?
- How do i declare a 2d array using new?
- How do I register a custom filetype in iOS【链接】
- How do I run a 64-bit guest in VirtualBox?
- How do I instantiate a Queue object in java?
- How do I hide a menu item in the actionbar?
- How do I deploy a Flask application in IIS?
- How do I call a C++ function from C?
- How do I read in a character variable with varying length in a space delimited dataset?
- How do I read in a character variable with varying length in a space delimited dataset?
- How do I install a file in my local repository along with a generic POM?
- How do I debug JavaScript in Safari?
- How do I use Cygwin in Geophysics ?
- Linux下搭建SVN服务器
- ios学习之个人笔记(超级猜图)
- 7-1
- VC++ 外壳扩展编程之windows右键菜单
- Educational Codeforces Round 2 D. Area of Two Circles' Intersection
- How Do I Declare A Block in Objective-C? [备忘]
- CSS 类、伪类和伪元素区别详解
- iOS的推送机制
- org.aspectj.lang.JoinPoint-中文简要API
- java基础之Gui编程和反射
- linux中/etc与/var目录,各是什么意思?这两个目录下的文件有什么特点?
- linux0.11 内核启动代码分析(一)
- 非常简单的汇编翻译器
- 电子或通信领域当前的主流技术及其社会需求调查报告