Parsing a string, not from xml

Discussion in 'iOS Programming' started by lowcountry01, Aug 13, 2009.

  1. lowcountry01 macrumors newbie

    Joined:
    Aug 13, 2009
    #1
    How would I parse a simple string that is not from xml?
    For example, I have two arrays: arrayName and arrayProduct. I have a string (myString) that looks like this:

    Crest;Toothpaste;;Polo;Shirts;;Webster;Dictionaries;;Starbucks;Coffee;;

    What I want to do is have the company name be inserted into arrayName, and the product inserted into arrayProduct. I will eventually populate a uitableview with these, having the company prominent, and the product the cell's subtitle.

    How would I go about parsing this?
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Did you even bother opening the NSString documentation?

    Take a look at the componentsSeparatedByString: method. Hint: you'll need to use it once to break it into NSStrings that hold a pair each then again on each NSString you get from that.
     
  3. Troglodyte macrumors member

    Joined:
    Jul 2, 2009
    #3
    Has anyone else noticed that the person that wrote the documentation for that method was obviously a 'Porridge' fan - Norman, Stanley, Fletcher...
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Brilliant. For some reason I'd never noticed that :D
     

Share This Page