get value of NSString as an array?

Discussion in 'iOS Programming' started by begdev, Aug 15, 2009.

  1. begdev macrumors newbie

    Joined:
    Mar 14, 2009
    #1
    I'm learning C again, so that I really understand everything.
    My objective is to get the value of a uitextfield input, which I know how to... and then based on each letter in order do something different.
    So like if string[1] == a { NSLog(@"its a")}, if string[1] == b { NSLog(@"its a b")} and so on...

    Now I know that strings are basically arrays. So if I'm correct, this should be possible, i just get the length of it, then do it for each one.. I'm just having trouble putting this into ObjC code. thanks.
     
  2. drivefast macrumors regular

    Joined:
    Mar 13, 2008
    #2
    use a characterAtIndex: message for your string. (really, if you would just have taken a look the NSString documentation, this should have jumped right at you...)
     
  3. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #3
    Don't use characterAtIndex.

    NSStrings are not just a kind of array.

    Read the String Programming Guide.
     
  4. begdev thread starter macrumors newbie

    Joined:
    Mar 14, 2009
    #4
    yeah i just found that heh...
    but thanks anyway, documentation isn't really handy for learning the basics and stuff, so i kinda filed it in my head as, "not helpful" but, i guess it is after all.
     
  5. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
    So what are you using instead?
     
  6. begdev thread starter macrumors newbie

    Joined:
    Mar 14, 2009
    #6
    books. i just find that when you're learning in the beginning, the documentation isn't very useful for teaching you how to do things.
     
  7. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #7
    Good. At least you're using something.
     

Share This Page