title: How to load a txt file into an array
body: <p>I coded a method to load a txt file into an array. However, I'm not really happy with it as it looks terribly cumbersome to my beginner's eyes (I'm sure I don't need 50% of my code) and I am somehow wondering how I can specify the exact format of my txt file, e.g. NSUTF8StringEncoding.</p>
  
  <p>Here is my code:</p>
  
  <pre><code> NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
   NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents directory
  
   NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"Sample.txt"]; 
  
  if (filePath) { // check if file exists - if so load it:
      NSString *myText = [NSString stringWithContentsOfFile:filePath];
      if (myText) {textView.text=myText;}
  }
  </code></pre>
  
  <p>For any suggestions of how to polish this up and specify the right format, I'd be very grateful.</p>