equal
deleted
inserted
replaced
30 |
30 |
31 #pragma mark - |
31 #pragma mark - |
32 #pragma mark View lifecycle |
32 #pragma mark View lifecycle |
33 -(void) viewDidLoad { |
33 -(void) viewDidLoad { |
34 [super viewDidLoad]; |
34 [super viewDidLoad]; |
35 srandom(time(NULL)); |
|
36 |
35 |
37 voiceBeingPlayed = NULL; |
36 voiceBeingPlayed = NULL; |
38 |
37 |
39 // load all the voices names and store them into voiceArray |
38 // load all the voices names and store them into voiceArray |
40 // it's here and not in viewWillAppear because user cannot add/remove them |
39 // it's here and not in viewWillAppear because user cannot add/remove them |
127 } |
126 } |
128 |
127 |
129 NSString *voiceDir = [[NSString alloc] initWithFormat:@"%@/%@/",VOICES_DIRECTORY(),[voiceArray objectAtIndex:newRow]]; |
128 NSString *voiceDir = [[NSString alloc] initWithFormat:@"%@/%@/",VOICES_DIRECTORY(),[voiceArray objectAtIndex:newRow]]; |
130 NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:voiceDir error:NULL]; |
129 NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:voiceDir error:NULL]; |
131 |
130 |
132 int index = random() % [array count]; |
131 int index = arc4random_uniform((int)[array count]); |
133 |
132 |
134 voiceBeingPlayed = Mix_LoadWAV([[voiceDir stringByAppendingString:[array objectAtIndex:index]] UTF8String]); |
133 voiceBeingPlayed = Mix_LoadWAV([[voiceDir stringByAppendingString:[array objectAtIndex:index]] UTF8String]); |
135 [voiceDir release]; |
134 [voiceDir release]; |
136 lastChannel = Mix_PlayChannel(-1, voiceBeingPlayed, 0); |
135 lastChannel = Mix_PlayChannel(-1, voiceBeingPlayed, 0); |
137 } |
136 } |