334Combining Images with UIImage & CGContext – (Offscreen drawing)

In Cocoa NSImage has a lockFocus method, that allows to draw images offscreen and combine them into one.

[img lockFocus];
//...
[img unlockFocus];

On the iPhone, UIImage lacks the lockFocus methods, instead the following:

// Create new offscreen context with desired size
UIGraphicsBeginImageContext(CGSizeMake(64.0f, 64.0f));

// draw img at 0,0 in the context
[img drawAtPoint:CGPointZero];

// draw another at 0,0 in the context, maybe with an alpha value
[another drawAtPoint:CGPointZero];

// ... and other operations

// assign context to UIImage
UIImage *outputImg = UIGraphicsGetImageFromCurrentImageContext();

// end context
UIGraphicsEndImageContext();

73Concatenating Strings @”string1″ @”string2″ @”stringN”

That's basically it.

No more [@"string1" stringByAppendingString:@"string2"];

or [NSString stringWithFormat:@"string1%@", @"string1"];

just @"string1" @"string2" @"stringN" -> code>@"string1string2stringN"</code

The Objective-C 2.0 Programming Language.pdf, p131