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

justmyself

macrumors member
Original poster
Jan 2, 2009
32
0
I have a large text file of several hundred lines of text and needed to grab a specified line of text. Would I make an array of with each position holding one line of text, or is there a better approach?

Sorry if this seems so simple but I am new to Objective C and Cocoa. I don't mind taking the time to code the array out, but I have some concerns about the iphone and it's ability to handle an array of such size.

Thanks
 

drivefast

macrumors regular
Mar 13, 2008
128
0
your definition of the problem is insufficient. a recommendation depends a lot on whether you need to access one single line, one single time per run, or you would have to access several different lines at different points in time, or on whether the lines in the file are in the order you would access them, and so on. try to offer a few more details.
 

justmyself

macrumors member
Original poster
Jan 2, 2009
32
0
your definition of the problem is insufficient. a recommendation depends a lot on whether you need to access one single line, one single time per run, or you would have to access several different lines at different points in time, or on whether the lines in the file are in the order you would access them, and so on. try to offer a few more details.

I only need to access one line of text when the application is launched, and at no other time.

The line number needed would be determined by an int provided by a function. In the array I have coded now is like below

[textToBeDisplayed setStringValue:array[int]];

Additionally the text is static and does not be changed/saved etc...

Hope this helps.
 

drivefast

macrumors regular
Mar 13, 2008
128
0
then read the lines one by one, counting them, and declare victory when you get to the one you need. internally, reading the file into an array would mean always reading and parsing the whole file, whereas if you read it line by line chances are you need less operations.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.