I am making a battleships game to play in console – How do you NSLog strings so they appear as a 10 x 10 grid and not a long list. Each coordinate is @”X” object from the boardArray.
Ideally I would like to do it in a loop – but, whatever !
Thank you.
NSMutableArray *boardArray = [[NSMutableArray alloc]initWithCapacity:110];
NSMutableString *blank =[[NSMutableString alloc]initWithString:@"X"];
for (int x = 0; x < 101; x++) {
[boardArray insertObject:blank atIndex:x];
}
for (int x = 0; x < 100; x++){
// what goes here to print (NSLog) a 10 x 10 grid of objects
// each object is a string @"X" from the boardArray.
}
Quick Example:
Output: