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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:42:20+00:00 2026-06-13T12:42:20+00:00

I’m tried to get column array like following without NSDictionary. it works well. But

  • 0

I’m tried to get column array like following without NSDictionary.
it works well.

But I’d like to know if objective-c literal supports this feature.

Is there a literal to do like this?

e.g array[][0]?, array[*][0], array[?][0], etc..?

NSArray *array1 = @[@"AAa", @"BBB", @"CCC"];
NSArray *array2 = @[@"AAb", @"BBB", @"CCC"];
NSArray *array3 = @[@"AAc", @"BBB", @"CCC"];

array = @[array1, array2, array3];

NSArray *result;
result = [self getColumnArray:0]; // <- get array's [*][0]
NSLog(@"result is : %@", result);

result = [self getColumnArray:2]; // <- get array's [*][2]
NSLog(@"result is : %@", result);


- (NSArray *)getColumnArray:(NSUInteger)index {
    NSMutableArray *resultArray = [NSMutableArray array];

    for (NSArray *item in array) {
        [resultArray addObject:item[index]];
    }

    return resultArray;
}


Excuted result :

2012-10-29 16:00:24.550 testButton[28245:11303] result is : (
    AAa,
    AAb,
    AAc
)
2012-10-29 16:00:24.552 testButton[28245:11303] result is : (
    CCC,
    CCC,
    CCC
)
  • 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-06-13T12:42:21+00:00Added an answer on June 13, 2026 at 12:42 pm

    The following code will work:

    NSArray *arr = @[ @[@"A", @"B"], @[@"C", @"D"]];
    NSLog(@"%@", array[0][0]); // Logs 'A'
    

    Therefore you could do something like this to achieve your desired effect:

    // Log the 0 element of each NSArray within your primary array.
    NSArray *primaryArray = @[ @[@"A", @"1"], @[@"A", @"2"], @[@"A", @"3"] ];
    for (int i = 0; i < array.count; i++) {
    
         NSLog(@"%@", primaryArray[i][0]); // Logs "AAA"
    
    }
    // Or you can use a for (NSArray *arr in primaryArray) fast-enumeration loop.
    

    As far as I’m aware though, there is no syntax for:

    NSLog(@"%@", primaryArray[*][0]); // Could log "AAA"
    

    There are several reasons for this.

    1. There is no specification of how long primaryArray is.
    2. NSLog has no idea how many %@‘s it needs (similar reasons for other uses, e.g. how would you return primaryArray[*][0]?)
    3. You are condensing an O(n) process into a single call. This could be forgiven if there was documented API for it.
    4. For this to be possible, the * operator would have to be overloaded (in this case to a ‘wildcard’ function) and Objective-C does not support operator overloading (except when done inside the compiler, which I suppose is no longer ‘operator overloading’ but ‘adding a language feature’). Also, * already denotes a pointer in C and ? is used in the ?: ternary operator.
    5. Objective-C already has a fast-enumeration structure which handles these situations, if this syntax were to be added, you’d be reinventing the wheel a little.

    In short, a fast-enumeration loop is the best way to do what you want, and the nested [i][0] box syntax aids its readability slightly. I agree the wildcard syntax would be very handy in some cases (such as logging and enumeration), but I think it would be too difficult to implement succinctly across the board. Plus, since they overloaded ^ for blocks, they’re running out of usable operators!

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want to count how many characters a certain string has in PHP, but
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words

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.