• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Text file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Text file
      • From: Henrietta Read <email@hidden>
References: 
 >Text file (From: Henrietta Read <email@hidden>)

  • Prev by Date: Re: Xcode 3.23 broke my code signing [FIXED]
  • Next by Date: Re: Text file
  • Previous by thread: Text file
  • Next by thread: Re: Text file
  • Index(es):
    • Date
    • Thread