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 6535471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:22:39+00:00 2026-05-25T10:22:39+00:00

My method aims to extract information on a game level from an input string.

  • 0

My method aims to extract information on a game level from an input string. The input specifies the size of the 2D array playing area, as well as what items are present at what points in the 2D array.

For example, “4,3 . a,b,c . d,e,f . g,h,i . j,k,l” would comprise 4 columns and 3 rows, to look like this (without the hyphens):

a—d—g—j

b—e—h—k

c—f—i—l

The code works fine until the last line, where I get the error:
“Expected ‘:’ before ‘]’ token”.

I’ve been trying to solve this for a while, so I’ll be quite embarrassed if it’s something stupid I’ve missed! Any help would be much appreciated.

-(void)readLevelDataFromString:(NSString*)inputString {
    //remove spaces from the input
    NSString *tempString = [inputString stringByReplacingOccurrencesOfString:@" " withString:@""];

    //make mutable
    NSMutableString *levelDataString = [NSMutableString stringWithString:tempString];

    //trim first 4 characters, which we don't need
    [levelDataString deleteCharactersInRange:NSMakeRange(0, 4)];

    //separate whole string into an array of strings, each of which contains information on the particular column
    NSArray *levelDataStringColumns = [levelDataString componentsSeparatedByString:@"."];

    NSAssert([levelDataStringColumns count] == numColumns, @"In the level data string, the number of columns specified did not match the number of X tiles present.");

    NSString *columnString = [[NSString alloc] initWithString:[[levelDataStringColumns] objectAtIndex:0]];
}
  • 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-25T10:22:40+00:00Added an answer on May 25, 2026 at 10:22 am

    You have an extra set of []. You want:

    NSString *columnString = [[NSString alloc] initWithString:[levelDataStringColumns objectAtIndex:0]];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The method I am doing right now is breaking the string into array of
Every method I write to encode a string in Java using 3DES can't be
The method signature of a Java main method is: public static void main(String[] args)
Which method would you recommend to pass data from a child view back to
Method visibility in Ruby (public, protected, and private methods) has been well explained in
my method's like this:- protected string myMethod() { if (something) { string img =
I am trying to write a generic method for String conversion (purpose being I
I'm working on what aims to be a secure method of user registration and
Method from this question How to write a Ping method in Cocoa/Objective-C wasn't helpful,
MyThreadRun method is invoked from MyMethod like this NSArray* args = [NSArray arrayWithObjects:arg1, target,

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.