• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Dividing Strings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Dividing Strings


  • Subject: Dividing Strings
  • From: Chuck Rice <email@hidden>
  • Date: Sun, 12 Jan 2003 21:13:20 -0800

I am new to Cocoa and and kind of new to C, though I have been programming in assembler for years. I am trying to divide a string I have retrieved from a Cell Phone:

7,"4083747418",129,"El Grullenese, Mexican",0,0,255,0,1

I am using:

NSMutableString * aLine;
NSArray * listItems;

listItems = [aLine componentsSeparatedByString:@","];

To split a string into an array of strings. This works great for most lines, but as you can see, in the example, there is a comma in the quoted name field. It still parses, but is not what I wanted since everything past that gets stored in the wrong column.

My question is, is there a better function to accomplish this, or will I need to do the parsing the hard way with a loop, looking at each character? Cocoa seems to have a really rich feature set, so I thought there might be a better way. Any help would be appreciated. I have spent a lot of time looking, but there is an awful lot of doc to see. -Chuck-
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
  • Follow-Ups:
    • Newbie question- NSLayoutManager SetShowsInvisibleCharacters
      • From: Mark Munz <email@hidden>
    • Re: Dividing Strings
      • From: Alex Rice <email@hidden>
References: 
 >Re: NSDistributedNotification in a Foundation tool (From: Alex Rice <email@hidden>)

  • Prev by Date: RE: Apple and Cocoa (why don't they eat their own dog food?)
  • Next by Date: Re: Dividing Strings
  • Previous by thread: Re: NSDistributedNotification in a Foundation tool
  • Next by thread: Re: Dividing Strings
  • Index(es):
    • Date
    • Thread