Iterating through NSDictionary

Iteration through NSDictionary could be achieved at least in two ways: using NSArray with [NSDictionary allKeys] or NSEnumerator.
Snippets:

	NSArray *keyArray =  [bigUglyDictionary allKeys];
	int count = [keyArray count];
	for (int i=0; i < count; i++) {
		NSDictionary *tmp = [bigUglyDictionary objectForKey:[ keyArray objectAtIndex:i]];
	}
	NSEnumerator *enumerator = [bigUglyDictionary keyEnumerator];
	id key;
	while ((key = [enumerator nextObject])) {
		NSDictionary *tmp = [bigUglyDictionary objectForKey:key];
	}

Second way is a little bit faster, so if you work with huge dictionaries and have no need of array with their keys – use it.

Tags: , ,

CoreText CTFramesetterSuggestFrameSizeWithConstraints vs UILabel sizeWithFont

CoreText: set text font and alignment to CFAttributedString

CoreText example: Column Layout (correctly inverted text)

Changing UITableView width

Explode/split NSString

TouchXML installation guide

Parsing XML element attributes with TouchXML

UIColor cheatsheet: color list, conversion from and to RGB values

UINavigationBar with solid color or image background

Removing padding from UITextView

Getting NSDate from NSString

Getting day of the week from NSDate