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

  • Home
  • SEARCH
  • 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 762649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:25:37+00:00 2026-05-14T16:25:37+00:00

I have an array of strings that are comma separated such as: Steve Jobs,12,CA

  • 0

I have an array of strings that are comma separated such as:

Steve Jobs,12,CA
Fake Name,21,CA
Test Name,22,CA
Bill Gates,44,WA
Bill Nye,21,OR

I have those values in an NSScanner object so that I can loop through the values and get each comma seperated value using objectAtIndex.

So, what I would like to do, is group the array items into new arrays, based on a value, in this case, State. So, from those, I need to loop through, checking which state they are in, and push those into a new array, one array per state.

CA Array:
Steve Jobs,12,CA
Fake Name,21,CA
Test Name,22,CA

WA Array:
Bill Gates,44,WA

OR Array:
Bill Nye,21,OR

So in the end, I would have 3 new arrays, one for each state. Also, if there were additional states used in the first array, those should have new arrays created also.

Any help would be appreciated!

  • 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-14T16:25:37+00:00Added an answer on May 14, 2026 at 4:25 pm

    You can use a NSMutableDictionary of NSMutableArrays – if the state encountered isn’t yet in the dictionary, add a new array.

    NSMutableArray* arr = [states objectForKey:state];
    if (arr == nil) {
        arr = [NSMutableArray array];
        [states setObject:arr forKey:state];
    }
    

    Then you can insert values into the array, preferably as objects though as Dave DeLong mentions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a comma-separated string that I want to convert into an array, so
I have an array of strings that I want to use for button titles
I have an array of input strings that contains either email addresses or account
I have a variable that contains : Sometimes array of strings and sometimes array
I have a comma separated value table that I want to read in Python.
I have a one-dimensional array of strings in JavaScript that I'd like to turn
I have a std::string that contains comma separated values, i need to store those
I have a java applet text area that I paste strings separated by a
I have an array in javascript. This array has strings that contains commas (,).
I have a string that has been converted into an 2D Array in js.

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.