Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

5. Concurrency > 5.1. Constructing Block Objects

5.1. Constructing Block Objects

Problem

You want to be able to write your own block objects or use block objects with iOS SDK classes.

Solution

You just need to understand the basic differences between the syntax of block objects and classic C functions. These differences are explained in the Discussion section.

Discussion

Block objects can either be inline or coded as independent blocks of code. Let’s start with the latter type. Suppose you have a method in Objective-C that accepts two integer values of type NSInteger and returns the difference of the two values, by subtracting one from the other, as an NSInteger:

- (NSInteger) subtract:(NSInteger)paramValue
                  from:(NSInteger)paramFrom{

  return paramFrom - paramValue;

}

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial