★ TouchArcade needs your help. Click here to support us on Patreon.

Assign specific value to random

08-06-2009, 04:12 AM
#1
Joined: Aug 2009
Posts: 1
Assign specific value to random

Hello i try to use arc4random function to estract sono text from a file, but the file have 100 lines and i'd like that the random function estract only a specific random line such as 6 - 12 - 18 - 24 - 30 . . . multiple of 6.
it's possible?

This is my actual code
Code:
int numLines = [rowFile count];
	
	
	
	int row = arc4random() % numLines;
08-06-2009, 08:00 AM
#2
How about this?

Code:
int numLines = [rowFile count];
int row = 6*(arc4random() % (numLines/6));

Check out Sudoku Grab for the iPhone - take a photo and play the puzzle
08-06-2009, 08:04 AM
#3
Joined: Mar 2009
Posts: 659
you could use something like

row = random()%(numLines/6) * 6;