Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6764589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:36:42+00:00 2026-05-26T14:36:42+00:00

I am making a battleships game to play in console – How do you

  • 0

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.

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:36:43+00:00Added an answer on May 26, 2026 at 2:36 pm

    Quick Example:

    // Create Array (01, 02, 03, 04, 05, etc.)
    
    NSMutableArray *theArray = [[NSMutableArray alloc]init];
    for (int i = 0; i < 100; i++) {
        [theArray addObject:[NSString stringWithFormat:@"%02d",i]];
    }
    
    // Print Array
    
    for (int i = 0; i < 10; i++) {
        NSArray *subArray = [theArray subarrayWithRange:NSMakeRange(0+(i*10),10)];
        NSLog(@"%@",[subArray componentsJoinedByString:@" "]);
    }
    

    Output:

    00 01 02 03 04 05 06 07 08 09
    10 11 12 13 14 15 16 17 18 19
    20 21 22 23 24 25 26 27 28 29
    30 31 32 33 34 35 36 37 38 39
    40 41 42 43 44 45 46 47 48 49
    50 51 52 53 54 55 56 57 58 59
    60 61 62 63 64 65 66 67 68 69
    70 71 72 73 74 75 76 77 78 79
    80 81 82 83 84 85 86 87 88 89
    90 91 92 93 94 95 96 97 98 99
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a battleships game, so when I pass something such as A10 into
Making a search result list (like in Google) is not very hard, if you
Making game of life I need to a have a grid that is 30x20
Making websites that appear correctly in IE is a big problem. Is there any
Making a drop down list for my JSP and the values I'm entering won't
Making a new shooter game here in the vein of Galaga (my fav shooter
I am making a battleship game for a project. While I have completed the
Making an uno game for a project. all 108 cards are located in a
Making a game with OpenGL/GLUT and C++. I've heard the easiest way to manage
Im making a Spotify application. When you play a song, the application will show

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.