Extract string from string-array?

Discussion in 'iOS Programming' started by Danneman101, May 10, 2009.

  1. Danneman101 macrumors 6502

    Joined:
    Aug 14, 2008
    #1
    Im trying to extract a NSString from a NSArray that is populated with strings, but keep getting "incompatible types in initialization".

    Code:
    NSArray *buttonNamesSecondRow = [NSArray arrayWithObjects:@"A", @"B", @"C", @"D", @"E", nil];	
    NSString *letter = buttonNamesSecondRow[2]; // Trying to get the "C"
    }
    
    I must be missing some kind of type-cast, but I cant find the syntax for doing this correctly. Any ideas?
     
  2. BlackWolf macrumors regular

    Joined:
    Apr 9, 2009
    #2
    have you ever tried the objC way?
    Code:
    NSString *letter = [buttonNamesSecondRow objectAtIndex:2];
    
    see if that works. if it doesn't ... strange :D
     
  3. Danneman101 thread starter macrumors 6502

    Joined:
    Aug 14, 2008
    #3
    Argh!!! Ill never get the hang of the obj-c syntax :/

    Thanks for the input - works fine :)
     

Share This Page