• 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: stringWithUTF8String: Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: stringWithUTF8String: Question


  • Subject: Re: stringWithUTF8String: Question
  • From: j o a r <email@hidden>
  • Date: Tue, 6 May 2003 08:36:36 +0200

Since you start out with raw data, perhaps you should rather use this method when creating the string:

- (id)initWithData:(NSData *)data encoding:(NSStringEncoding)encoding

j o a r

On Tuesday, May 6, 2003, at 08:14 Europe/Stockholm, Karl Goiser wrote:

I am having trouble with the stringWithUTF8String: method:

I am reading data from a file - UTF data - like this:

NSData * contentsData = [NSData dataWithContentsOfFile: pathName];
if (contentsData) {
contents = [NSString stringWithUTF8String: [contentsData bytes]];
...

Intermittently, contents will return as nil. Well, actually, about 50% of the time! I can sit in ProjectBuilder, and hit command-R and sometimes this routine will work and sometimes it will fail.

This is always on the same, unchanged file which is about 700 bytes long.


Does anybody have any inkling why this might be so? It's got me!
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: stringWithUTF8String: Question
      • From: Karl Goiser <email@hidden>
References: 
 >stringWithUTF8String: Question (From: Karl Goiser <email@hidden>)

  • Prev by Date: NSTabView
  • Next by Date: Re: stringWithUTF8String: Question
  • Previous by thread: stringWithUTF8String: Question
  • Next by thread: Re: stringWithUTF8String: Question
  • Index(es):
    • Date
    • Thread