title: NSString -initWithContentOfFile error - Objective-C
body: <p>I'm trying to load to an <code>NSString</code>, the content of my file named <code>names.txt</code>, in the directory of the project. To do this, I have the following code :</p>
  
  <pre><code>    NSError *error = nil;
      NSString *names = [[NSString alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"names" ofType:@"txt"] encoding:NSASCIIStringEncoding error:&amp;error];
      if (error != nil) {
          [NSException raise:@"Error reading file :" format:@"%@",error];
      }
  </code></pre>
  
  <p>And I'm getting <code>*** Terminating app due to uncaught exception 'Error reading file :', reason: 'Error Domain=NSCocoaErrorDomain Code=258 "The file name is invalid."'</code>. I couldn't find any other cases like that. What's wrong with this code?</p>