Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Fontano

macrumors member
Original poster
Jun 27, 2008
72
0
I have my app working with my REST webservices.
However, the XML overhead is un-believably horrible on EDGE connections, so-so on 3G, and okay on Wi-FI (or when on the simulator).

I have turned my REST service to output a deliminited TXT file instead of a well formed XML. This has resulted in a 92% drop in the file size.

Is there a code sample out there, on what is the best way to read, load, and parse out the deliminted lines. So I can load them into my custom class objects that I am using in the current app.
 

MarcVanH

macrumors newbie
Sep 12, 2008
15
0
Here is code I used recently to parse out each line in a text file:

Code:
           NSArray *fileData = [[NSString stringWithContentsOfFile:myFile] componentsSeparatedByString:@"\r\n"];
            for (NSString *dataLine in fileData) {
                .....

You could use the same code to parse each line of data - just change @"\r\n" to @",".
 

iphonejudy

macrumors 6502
Sep 12, 2008
301
1
Reading .txt file from http

I have my app working with my REST webservices.
However, the XML overhead is un-believably horrible on EDGE connections, so-so on 3G, and okay on Wi-FI (or when on the simulator).

I have turned my REST service to output a deliminited TXT file instead of a well formed XML. This has resulted in a 92% drop in the file size.

Is there a code sample out there, on what is the best way to read, load, and parse out the deliminted lines. So I can load them into my custom class objects that I am using in the current app.


Hi,

Have u solved this task,I also want to access a txt file from htttp(htttp://aaa/a/a.txt)

Can u give me the code?

Regards
judy
 

russellelly

macrumors regular
Jun 23, 2006
139
41
Glasgow, UK
Hi,

Have u solved this task,I also want to access a txt file from htttp(htttp://aaa/a/a.txt)

Can u give me the code?

Regards
judy

Code:
NSString *urlContents = [NSString stringWithContentsOfURL:
						   [[NSURL alloc] initWithString:
							@"htttp://aaa/a/a.tx"]];

should do the trick.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.