我很难尝试每秒获取一个随机数并记录它以及它的运行平均值。
代码:
-(void)generateNumber:(NSTimer *)numberEachSecond
{
NSUInteger random = (arc4random() % 1000) +1;
NSMutableArray *listOfNumbers = [[NSMutableArray alloc]init];
NSNumber *number = [NSNumber numberWithInteger:random];
[listOfNumbers addObject:number];
// NSNumber *counter = 0;
for (NSNumber *generatedNumber in listOfNumbers)
{
NSLog(@"%@",generatedNumber);
}
NSLog(@"%@", listOfNumbers);
}