Skip to main content

Abstract

In the previous chapters, we learned that a Block is an anonymous function together with automatic variables. In this chapter, we look at the details of a Block with its implementation to see what happens under the hood of Blocks. We start with the basic idea of the Block’s implementation and then we show various situations to see how the Blocks work, such as how automatic variables are captured, how Blocks and __block variables are stored in memory, and how objects are captured by Blocks. Also, we show some pitfalls of Blocks related to circular reference and copy/release methods. All the example source code assumes ARC is enabled except where specified.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 16.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2012 Kazuki Sakamoto

About this chapter

Cite this chapter

Sakamoto, K., Furumoto, T. (2012). Blocks Implementation. In: Pro Multithreading and Memory Management for iOS and OS X. Apress. https://doi.org/10.1007/978-1-4302-4117-1_5

Download citation

Publish with us

Policies and ethics