I am implementing a CATiledLayer
into a UIScrollView
. In the CATiledLayer
, I have a function to draw the layers like so:
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx {
CGContextTranslateCTM(ctx, 0.0f, 0.0f);
CGContextScaleCTM(ctx, 1.0f, -1.0f);
CGRect box = CGContextGetClipBoundingBox(ctx);
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"urlhere"]];
UIImage *image = [[UIImage alloc] initWithData:data];
CGContextDrawImage(ctx, box, [image CGImage]);
[image release];
[data release];
}
The problem is that when each tile is downloading it blocks the downloads of other tiles. I would very much prefer if these tiles were downloaded in parallel. In particular it blocks the downloads of another UI element that I am not in control over.
Basically, I just need to know how to download data asynchronously in a CATiledLayer
drawing message.