Re: Text file
Re: Text file
- Subject: Re: Text file
- From: Jens Alfke <email@hidden>
- Date: Thu, 15 Apr 2010 09:22:09 -0700
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 (email@hidden)
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:
This email sent to email@hidden
References: | |
| >Text file (From: Henrietta Read <email@hidden>) |