--- a/project_files/HedgewarsMobile/Classes/LevelViewController.m Tue Sep 08 19:20:58 2015 +0300
+++ b/project_files/HedgewarsMobile/Classes/LevelViewController.m Mon Nov 16 22:57:24 2015 +0300
@@ -31,7 +31,6 @@
#pragma mark View lifecycle
-(void) viewDidLoad {
[super viewDidLoad];
- srandom(time(NULL));
NSArray *array = [[NSArray alloc] initWithObjects:
NSLocalizedString(@"Brutal",@""),
@@ -59,10 +58,6 @@
[self.tableView setContentOffset:CGPointMake(0,0) animated:NO];
}
--(void) viewWillDisappear:(BOOL)animated {
- // stuff like checking that at least 1 field was selected
-}
-
#pragma mark -
#pragma mark Table view data source
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
@@ -133,7 +128,7 @@
if (theSwitch.on) {
numberOfSections = 2;
[self.tableView insertSections:sections withRowAnimation:UITableViewRowAnimationFade];
- level = 1 + (random() % ([levelArray count] - 1));
+ level = 1 + arc4random_uniform((int)[levelArray count] - 1);
} else {
numberOfSections = 1;
[self.tableView deleteSections:sections withRowAnimation:UITableViewRowAnimationFade];
@@ -141,9 +136,9 @@
}
[sections release];
- DLog(@"New level is %d",level);
+ DLog(@"New level is %ld", (long)level);
for (NSMutableDictionary *hog in hogs)
- [hog setObject:[NSNumber numberWithInt:level] forKey:@"level"];
+ [hog setObject:[NSNumber numberWithInteger:level] forKey:@"level"];
[self.tableView reloadData];
[[NSNotificationCenter defaultCenter] postNotificationName:@"setWriteNeedTeams" object:nil];
@@ -153,8 +148,8 @@
#pragma mark -
#pragma mark Table view delegate
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- int newRow = [indexPath row];
- int oldRow = (self.lastIndexPath != nil) ? [self.lastIndexPath row] : -1;
+ NSInteger newRow = [indexPath row];
+ NSInteger oldRow = (self.lastIndexPath != nil) ? [self.lastIndexPath row] : -1;
if ([indexPath section] != 0) {
if (newRow != oldRow) {
@@ -162,8 +157,8 @@
NSInteger level = newRow + 1;
for (NSMutableDictionary *hog in hogs)
- [hog setObject:[NSNumber numberWithInt:level] forKey:@"level"];
- DLog(@"New level is %d",level);
+ [hog setObject:[NSNumber numberWithInteger:level] forKey:@"level"];
+ DLog(@"New level is %ld", (long)level);
// tell our boss to write this new stuff on disk
[[NSNotificationCenter defaultCenter] postNotificationName:@"setWriteNeedTeams" object:nil];