Skip to content

Instantly share code, notes, and snippets.

@frijole
Created March 15, 2011 00:31
Show Gist options
  • Save frijole/870125 to your computer and use it in GitHub Desktop.
Save frijole/870125 to your computer and use it in GitHub Desktop.
// NEW RANDOM ACTION
NSString *lineSources = [[NSBundle mainBundle] pathForResource:@"quotes" ofType:@"plist"];
NSDictionary *lines = [[NSDictionary alloc] initWithContentsOfFile:lineSources];
NSMutableArray *line1Strings = [lines valueForKey:@"line1"];
NSMutableArray *line2Strings = [lines valueForKey:@"line2"];
NSMutableArray *line3Strings = [lines valueForKey:@"line3"];
NSMutableArray *line4Strings = [lines valueForKey:@"line4"];
NSMutableArray *line5Strings = [lines valueForKey:@"line5"];
NSMutableArray *line6Strings = [lines valueForKey:@"line6"];
int random[6]; for (int n = 0; n < 6; n++) {random[n] = arc4random() % [line1Strings count];};
line1Text.text = [line1Strings objectAtIndex:random[0]];
line2Text.text = [line2Strings objectAtIndex:random[1]];
line3Text.text = [line3Strings objectAtIndex:random[2]];
line4Text.text = [line4Strings objectAtIndex:random[3]];
line5Text.text = [line5Strings objectAtIndex:random[4]];
line6Text.text = [line6Strings objectAtIndex:random[5]];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment