• 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
how to build data parser
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to build data parser


  • Subject: how to build data parser
  • From: Daniel Child <email@hidden>
  • Date: Sat, 26 Mar 2005 17:27:53 -1000

Hi All,

In my short time doing Objective-C, I've had to parse data files on several occasions and want to build a more generic parser. I'm thinking along these lines.

+ (DataParser *)parserWithFieldDelim:(NSString *)fd andRecordDelim:(NSString *)rd;
- (NSMutableArray *)parseFileAtPath:(NSString *)path withObjectType:(NSObject *)ot;

The parse file method would return an array of objects. I'm stuck with two things I haven't done before. How do I specify an object type (e.g. Word class or Stroke class object)? And once I have scanned individual lines of text, how can assign the parsed fields to the correct member variable fields of the object class being passed in?

I think I would want to be able to specify the number of expected fields and the field types (string or number), but am not sure how an ordering of fields is accomplished. Thinking back to my days with Fourth Dimension, I'm looking for a way to convey that:

field 1 is a string
field 2 is a number

such that if, for example, a Word class, has

NSString *word
NSNumber *frequency

as instance variables, there will be a way to init members of the class properly. Any ideas how to go about doing this?

Thanks,
Daniel

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: how to build data parser
      • From: "M. Uli Kusterer" <email@hidden>
    • Re: how to build data parser
      • From: "M. Uli Kusterer" <email@hidden>
    • Re: how to build data parser
      • From: Pandaa <email@hidden>
  • Prev by Date: Odd parse error when I try to build
  • Next by Date: Re: Odd parse error when I try to build
  • Previous by thread: Re: Saving State of NSOutlineView in Document-based App
  • Next by thread: Re: how to build data parser
  • Index(es):
    • Date
    • Thread