On Apr 15, 2010, at 8:50 AM, Henrietta Read wrote:

  NSError *error = nil;
  NSStringEncoding encoding;

[myMutableString setString:[NSString stringWithContentsOfFile:filePath
usedEncoding:&encoding error:&error]];

The call to -stringWithContentsOfFile: looks correct, but you're failing to check for errors. If it fails, it will return nil, and passing nil to setString: is illegal and will throw an exception.

This leaves the question of why -stringWithContentsOfFile: would fail. I'm not sure what heuristics that call uses, but you'd think it would be able to handle MacRoman, obsolete though it is.

but on some files (say, Western Mac OS Roman) it crashes.

The stack backtrace is a lot more useful than the disassmbly at the PC. If you're still having trouble, post the backtrace of the crash.

Actually, as far as I can tell, this isn't a crash but rather a breakpoint on throwing an Objective-C exception. Which fits with what I said above. Did you set "Stop On Objective-C Exceptions" in the Run menu?

—Jens_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to