`
圆代码
  • 浏览: 10144 次
  • 来自: 上海
最近访客 更多访客>>
社区版块
存档分类
最新评论

【转】Blocks编程要点[中文完整翻译版]- Blocks Programming Topics

iOS 
阅读更多

觉得不错,故转载一下,喜欢的就下载吧

---------------------------------------------------

Blocks编程要点

原著:Apple Inc. 

翻译:謝業蘭 

联系:xyl.layne@gmail.com 

鸣谢:有米移动广告平台 

             CocoaChina 社区


译名:Blocks编程要点
原文:Blocks Programming Topics
链接:

http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/Blocks/Articles/00_Introduction.html#//apple_ref/doc/uid/TP40007502-CH1-SW1

文档下载:

http://vdisk.weibo.com/s/1Bi9K

 

【翻译缘由—翻译本身也是强化学习的过程】
之前一直在CocoaChina上面潜水,虽然做iOS开发也快2年了,但是总觉得缺少了点什么。以前查看英文API文档,有些细节总是记不住,每次看完之后也没什么印象。忽然有一天有人向我抱怨说查看官方英文API文档太痛苦了,然后我就想如果我把一些常用的官方文档翻译为中文的话,或许可以帮助这批需要帮助的人,然后偶就心血来潮,开始了自娱自乐的翻译之旅。帮助别人的同时,自己也获得快乐。

Block是iOS 4.0之后添加的新特性支持。本人亲测感觉使用Block最大的便利就是简化的回调过程。以前使用UIView的动画,进程要控制动画结束后进行相应的处理。iOS 4.0之后,UIView新增了对Block的支持,现在只要使用简单的一个Block代码就可以在写动画的代码部分直接添加动画结束后的操作。还有就是在使用Notification 时候Block也非常有帮助。反正多用就可以体会到Block的优美了。
对了,使用Block要谨记别造成对象互相引用对方导致引用计数进入一个循环导致对象无法被释放。iOS 5.0之后的ARC也是无法解决该潜在的互相引用的问题的。所以写Block的时候要注意这点。因为Block往往在后台自动对一些它引用了的对象进行retain操作。具体形式这里就不距离了,大家在使用的时候多体会一下。

本文在翻译过程中发现很多地方直译成中文比较晦涩,所以采用了意译的方式,这不可避免的造成有一些地方可能和原文有一定的出入,所以如果你阅读的时候发现有任何的错误都可以给我发邮件:xyl.layne@gmail.com

大家也可以关注我微博一起沟通交流学习。
微博地址: http://weibo.com/u/1826448972

最后希望这篇文档能帮上那些感觉看官方英文文档困难的人。如果可以我还是推荐尽量查看英文原文档,毕竟那是原汁原味,翻译总无法避免有一定的疏漏。

其实之前没有打算要翻译该文档的,只是中间自己学习到Block用法,心想干脆就一边学习一边翻译好了。或许大家对Blocks不太熟悉,如果你原本没有用过block的话,那可以看看本文档,你会发现其实block很好用。

下期预告:Instruments用户指南

因为翻译的时候写在word里面,格式太多,图片上传麻烦,所以干脆直接转换为PDF提供给大家下载。

以下提供目录预览:

目录

简介
本文档结构
第一章    BLOCKS入门
1.1    声明和使用一个BLOCK
1.2    直接使用BLOCK
1.3    COCOA的BLOCKS
1.4    __BLOCK变量
第二章    概念概述
2.1    BLOCK功能
2.2    用处
第三章    声明和创建BLOCKS
3.1    声明一个BLOCK的引用
3.2    创建一个BLOCK
3.3    全局BLOCKS
第四章    BLOCKS和变量
4.1    变量类型
4.2    __BLOCK存储类型
4.3    对象(OBJECT)和BLOCK变量
4.3.1    Objective-C对象
4.3.2    C++对象
4.3.3    Blocks
第五章    使用BLOCKS
5.1    调用一个BLOCK
5.2    使用BLOCK作为函数的参数
5.3    使用BLOCK作为方法的参数
5.4    拷贝BLOCKS
5.5    需要避免的模式
5.6    调试
结束语
推荐资源


转载自:http://www.cocoachina.com/bbs/read.php?tid=87593
转载此文请注明:http://dev.youmi.net/2011/12/blocks-programming-topics.html
 更多iOS开发者资料:http://dev.youmi.net/2011/12/threading-programming-guide.html
分享到:
评论

相关推荐

    Blocks编程要点[中文完整翻译版]- Blocks Programming Topics

    ### Blocks编程要点详解 #### 简介 Block对象是一种C级别的语法和运行时特性,在iOS 4.0及以后的版本中得到了广泛的应用。它们类似于标准C函数,但不仅包含可执行代码,还能捕获并维护一组局部变量的状态。这种...

    [翻译中文]4本iOS开发Apple官方原版教材-Core Animation.....

    关于iOS开发辅助的四本书,经謝業蘭朋友翻译,供大家学习参考。 核心动画编程指南.pdf-- (Apple官方原版:Core Animation Programming ...Blocks 编程要点.pdf------ (Apple官方原版:Blocks Programming Topics.pdf)

    Blocks Programming Topics

    ### Blocks Programming Topics #### Introduction Blocks是C语言层面的一个语法和运行时特性,它们类似于标准C函数,但除了可执行代码之外,还可以包含对自动(栈)或管理(堆)内存中的变量绑定。这意味着一个块...

    Blocks变成要点

    因此,Apple提供的《Blocks Programming Topics》文档是学习和实践Blocks编程的宝贵资源。通过对文档的学习,开发者可以深入理解Blocks的声明和创建过程,掌握如何在程序中有效地使用Blocks,提升编程效率和代码质量...

    Objective-C Programming: The Big Nerd Ranch Guide (2nd Edition)

    Objective-C Programming: The Big Nerd Ranch Guide (2nd Edition).epub (epub 格式) Want to write iOS apps or desktop Mac applications? This introduction to programming and the Objective-C language is ...

    iOS block编程要点

    在Apple官方文档《Blocks Programming Topics》中,详细介绍了block编程的各种要点,包括block的声明、创建、使用、与变量的关系等方面。文档结构清晰,从基础知识到高级应用,逐步深入,适合初入门的iOS开发人员...

    Oracle Database 10g PL-SQL Programming

    ### Oracle Database 10g PL/SQL Programming #### 1. Introduction to PL/SQL PL/SQL (Procedural Language for SQL) is a procedural extension to SQL that provides a powerful way to manipulate data within...

    QGIS Python Programming Cookbook - Second Edition

    QGIS Python Programming Cookbook - Second Edition by Joel Lawhead English | 14 Mar. 2017 | ASIN: B01MRP7T3B | 464 Pages | AZW3 | 9.26 MB Master over 170 recipes that will help you turn QGIS from a ...

    iOS 4 高级编程

    Welcome to Advanced iOS 4 Programming, a text that targets the development of mobile applications on devices (such as the iPhone, iPad, and iPod touch) running the iOS 4 operating system. This text ...

    C PROGRAMMING TUTORIAL

    ### C Programming Tutorial #### CLanguage Overview C is a general-purpose, procedural computer programming language developed in the early 1970s by Dennis Ritchie at Bell Labs. It is one of the most...

    Learn Java 17 Programming 2nd Edition

    ### Java 17 Programming Key Concepts and Features The title "Learn Java 17 Programming 2nd Edition" indicates that this book is an updated guide designed to teach the basics of Java programming, ...

    C Programming

    ### C Programming #### An Introduction to Computers In this section, the document begins by explaining the fundamentals of computers, which is essential for understanding programming and the context ...

    iOS 10 Programming for Beginners

    iOS 10 Programming for Beginners English | 27 Dec. 2016 | ISBN: 1786464500 | 678 Pages | AZW3/MOBI/EPUB/PDF (conv) | 157.74 MB Key Features Use Swift 3 and latest iOS 10 features to build awesome ...

    Beginning Ruby From Novice to Professional, Second Edition

    * Takes readers from basic programming skills to web development with topics like Ruby-based frameworks and GUI programming * Covers many ancillary technologies in order to provide a broader picture...

    Practical Database Programming with Java

    A novel writing style is adopted to attract students or beginning programmers who are interested in learning and developing practical ...blocks of codes found in traditional database programming books....

    iOS Programming: The Big Nerd Ranch Guide (2nd Edition)

    iOS Programming: The Big Nerd Ranch Guide (2nd Edition) Product Description In this book, the world’s leading Apple platform development trainers offer a complete, practical, hands-on introduction ...

    Cours-VB-NET-2010-Developpez-com

    The course covers essential topics ranging from basic programming concepts to advanced features specific to VB.NET. Some of the key areas include: - **Programming Fundamentals:** Understanding objects...

    Programming WCF Services, 3rd Edition

    Hailed as the definitive treatment of WCF, this book provides unique insight, rather than documentation, to help you learn the topics and skills you need for building WCF-based applications that are ...

Global site tag (gtag.js) - Google Analytics