ksnowlv

回顾过去,总结以往;立足现在,铭记当下;技术为主,笔记而已.

iPhone之block_全局block

| Comments

可以将一个块变量作为全局块指针变量使用。 如下声明:

1
2
3
void (^showInfomationBlock)(NSString* infomaion) = ^(NSString* infomaion){
    NSLog(@"infomation:%@", infomaion);
};

可以如下调用:

1
showInfomationBlock(@"我是全局块");

输出为

2013-04-07 13:59:28.037 test[8201:c303] infomation:我是全局块

和全局变量,静态变量类似,全局block不会超过作用域,不用担心CRASH。

Comments

comments powered by Disqus
Included file 'custom/after_footer.html' not found in _includes directory