title: Objective-C: Reading a file line by line
body: <p>What is the appropriate way of dealing with large text files in Objective-C? Let's say I need to read each line separately and want to treat each line as an NSString. What is the most efficient way of doing this?</p>
  
  <p>One solution is using the NSString method:</p>
  
  <pre><code>+ (id)stringWithContentsOfFile:(NSString *)path 
        encoding:(NSStringEncoding)enc 
        error:(NSError **)error 
  </code></pre>
  
  <p>and then split the lines with a newline separator, and then iterate over the elements in the array. However, this seems fairly inefficient. Is there no easy way to treat the file as a stream, enumerating over each line, instead of just reading it all in at once? Kinda like Java's java.io.BufferedReader.</p>