Coobjc Open Sourcced: Alibaba’s Open Source Coroutine Framework for iOS Developers

Offering full coroutine support for iOS languages

The Problem of Async Programming

All About Coobjc: From Core Features to Source Code

System architecture

Operating principles

Example code

//Asynchronously loading data from the network
[NSURLSession sharedSession].configuration.requestCachePolicy = NSURLRequestReloadIgnoringCacheData;
NSURLSessionDownloadTask *task = [[NSURLSession sharedSession] downloadTaskWithURL:url completionHandler:
^(NSURL *location, NSURLResponse *response, NSError *error) {
if (error) {

//Parsing data in child threads and generating images
dispatch_async(dispatch_get_global_queue(0, 0), ^{
NSData *data = [[NSData alloc] initWithContentsOfURL:location];
UIImage *image = [[UIImage alloc] initWithData:data];
dispatch_async(dispatch_get_main_queue(), ^{
//Dispatch to the main thread to view the image
imageView.image = image;

//Main thread creates coroutine
//Asynchronous network data loading
NSData *data = await([NSURLConnection async_sendAsynchronousRequest:request response:nil error:nil]);
//Asynchronous image parsing
UIImage *image = await([UIImage async_imageWithData:data]);
//Show image
imageView.image = image;


In a Nutshell


Ease of use



A final thought

— Abelson and Sussman

Alibaba Tech

First-hand & in-depth information about Alibaba's tech innovation in Artificial Intelligence, Big Data & Computer Engineering. Follow us on Facebook!