Skip to content

Commit bd5ad01

Browse files
author
Jim Puls
committed
Better explain different ways of getting images.
1 parent 5d5869d commit bd5ad01

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

CodeGenTestApp/CGTAMasterViewController.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,16 @@ - (IBAction)sliderValueChanged:(UISlider *)sender;
5858

5959
- (NSArray *)flagImages;
6060
{
61-
// return @[[UIImage imageNamed:@"USA"], [UIImage imageNamed:@"Canada"], [UIImage imageNamed:@"UK"], [UIImage imageNamed:@"Austrlia"]];
62-
// return @[[CGTAImagesCatalog usaImage], [CGTAImagesCatalog canadaImage], [CGTAImagesCatalog ukImage], [CGTAImagesCatalog australiaImage]];
61+
NSArray *allFlagImages = nil;
62+
63+
// Initial version: full of strings that you have to type correctly!
64+
// Misspell any of these and your app will crash on trying to add `nil` to an array.
65+
allFlagImages = @[[UIImage imageNamed:@"USA"], [UIImage imageNamed:@"Canada"], [UIImage imageNamed:@"UK"], [UIImage imageNamed:@"Australia"]];
66+
67+
// New version: get the properly compiler-checked spelling from the image catalog.
68+
allFlagImages = @[[CGTAImagesCatalog usaImage], [CGTAImagesCatalog canadaImage], [CGTAImagesCatalog ukImage], [CGTAImagesCatalog australiaImage]];
69+
70+
// But really, why not use a little runtime hackery because we can?
6371
return [CGTAImagesCatalog allImages];
6472
}
6573

0 commit comments

Comments
 (0)