how to build data parser
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