NSData to ...?
I have an NSString path to a text file (presumably)
I would like to be able to parse this file, the best I can gather is:
where do I go from here to convert it into something more readable. Here is actually what is in the file:
and so on.
any help is appreciated. (Using Objective-C for those not able to quickly pick up on that -_-)
I would like to be able to parse this file, the best I can gather is:
Code:
NSFileWrapper *fwap = [[NSFileWrapper alloc] initWithPath:afile];
NSData *tehdata = [fwap serializedRepresentation];where do I go from here to convert it into something more readable. Here is actually what is in the file:
Code:
B1 264 5.993 100
B1 266 125.76 200
B4 264 12.36 100any help is appreciated. (Using Objective-C for those not able to quickly pick up on that -_-)
use NSString's stringWithContentsOfFile, and then use componentsSeparatedByString:@" " to get an array of all of those things.
"When you dream, there are no rules..."
Taxxodium Wrote:use NSString's stringWithContentsOfFile, and then use componentsSeparatedByString:@" " to get an array of all of those things.*licks*
thank you! ^_^
yay for follow up (yes yes, I am ever so silly for wanting to use cocoa for text parsing):
M'k, I have a line of stuff:
all stuck in a single NSString.
I want to first read up to a letter. so it would take all non letter up to the first letter then I can stick that into a string. then I move on (maybe delete what I have read so far) and then read up to the comma. then up to the white space, then up to next white space, and so on.
Anybody have a good pointer as to how I can start this?
M'k, I have a line of stuff:
Code:
8B,1 10.96 150.86 59 584 4111I want to first read up to a letter. so it would take all non letter up to the first letter then I can stick that into a string. then I move on (maybe delete what I have read so far) and then read up to the comma. then up to the white space, then up to next white space, and so on.
Anybody have a good pointer as to how I can start this?
NSScanner is your friend.
OneSadCookie Wrote:NSScanner is your friend.aha, just what I was looking for!

