-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|597|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Snippet Home -> Misc


 
Cower
Created : 11 October 2009
Edited : 11 October 2009
System : Mac
Language : C#

Example of Blocks/Dispatch Queues in Obj-C

A simple implementation of a Range type in Obj-C that uses blocks and dispatch queues.

Some code to, hopefully, illustrate the use of blocks and dispatch queues (libdispatch) together in Objective-C. You should be able to use blocks in C if you grab Clang under Linux. I don't know if it works under Windows, I wouldn't be surprised if it did. However, libdispatch currently only works under Mac OS (since it's Apple tech), but given that it's open source, Linux may still get support for it.

At any rate, this isn't code that I'd use in any sort of real-world situation, but it works pretty well for illustrating the use of blocks and at least one asynchronous method of libdispatch.

Range.h


Range.m


main.m

 

Comments