Welcome to Soft32 Forums!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

How to scan a large text file line by line in Cocoa

 
Goto page Previous  1, 2
   Soft32 Home -> Mac -> Programmer Help RSS
Next:  in xcode 2.3  
Author Message
Michael Ash

External


Since: Jan 18, 2005
Posts: 1073



(Msg. 16) Posted: Tue Jul 18, 2006 11:23 pm
Post subject: Re: How to scan a large text file line by line in Cocoa [Login to view extended thread Info.]
Archived from groups: comp>sys>mac>programmer>help (more info?)

rhnlogic wrote:
> Michael Ash wrote:
>> halt wrote:
>> > Thanks for your help but this is not exactly what I'm looking for. I'm
>> > looking for what is considered the normal approach in Cocoa to read a
>> > file one line at a time. I don't want to read a 100MB file completely
>> > into some data structure (NSData, NString or memory-mapping) just to
>> > process it line by line. It would be a waste of memory.
>> >
>> > Is there no Cocoa equivalent of fgets() or getline() which both read
>> > only one line of text from a file (stream) ?
>>
>> Why bother with "equivalents" when you can just use the real thing?
>> Objective-C is a superset of C, so you can just use fgets() and such
>> directly.
>
> This still requires some helper functions to coerce NSFile objects
> into posix paths or FILE pointers that fopen or fgets accepts.

Not at all. Just as you can use fgets(), you can also use things such as
fopen().

If you really need to bridge it, though, it's not terribly hard.
[fileHandle fileDescriptor], dup(), then fdopen() and you have a FILE *.

--
Michael Ash
Rogue Amoeba Software
Back to top
Login to vote
Display posts from previous:   
Related Topics:
command line application - Hello all: I am using MAC OS X.3 and THe latest version of Xcode (1.2 I think). How do I set up a project to make a...

how to compile c++ at the cmd line? - hey all-- I'm a java/obj-c programmer and i picked up sams "teach yourself c++ in 10 min a day". i can comp...

How to run a command line tool? - Hi, A few of the Apple code examples build command line tools rather than proper apps. How do you 'run' these apps? I...

Ignore line endings in FileMerge ? - Hi, Is there a way to force FileMerge 2.0.4 (part of Xcode 1.5) to ignore line endings (Mac / Unix / DOS) when compar...

non-line-buffered key input in C? - I'm learning C from a book that uses the getche() function from the <conio.h> library to get instant keyboard ch...

non-line-buffered key input in C - I'm learning C from a book that uses the getche() function from the <conio.h> library. However, the preprocessor...
       Soft32 Home -> Mac -> Programmer Help All times are: Pacific Time (US & Canada) (change)
Goto page Previous  1, 2
Page 2 of 2

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum

Categories:
 Windows
 Linux
  Mac
 PDA



[ Contact us | Terms of Service/Privacy Policy ]