• 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: [NSString initWithData: encoding:]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [NSString initWithData: encoding:]


  • Subject: Re: [NSString initWithData: encoding:]
  • From: Robin Hermann <email@hidden>
  • Date: Mon, 17 Jan 2005 20:17:15 +0100

What a great list this is. You all make me feel humble...
Thanks.

Learning to walk, step by step.

Robin Hermann


On 17 jan 2005, at 18:46, Clark Cox wrote:

On Mon, 17 Jan 2005 18:31:46 +0100, Robin Hermann <email@hidden> wrote:

Then someone suggested: use [NSString initWithData: encoding:];
Tested the following code, resulting in a crash:
NSData *note = [record objectForKey:@"notes"];
if (note != Nil && [note isKindOfClass:[NSData class]]) {
NSString *noteString;
[noteString initWithData:note encoding:NSISOLatin1StringEncoding];
[notes setString:noteString];
}


ISO Latin1 is the default encoding of MySQL
Now I'm completely lost, what I'm doing wrong here?

You're never allocating noteString. Try this:

NSData *note = [record objectForKey:@"notes"];
if (note != Nil && [note isKindOfClass:[NSData class]]) {
       NSString *noteString = [[NSString alloc] initWithData:note
encoding:NSISOLatin1StringEncoding];
       [notes setString:noteString];
       [noteString release]; //Make sure to release it when you're done
}






Robin Hermann

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden




--
Clark S. Cox III
email@hidden
http://www.livejournal.com/users/clarkcox3/
http://homepage.mac.com/clarkcox3/


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >[NSString initWithData: encoding:] (From: Robin Hermann <email@hidden>)
 >Re: [NSString initWithData: encoding:] (From: Clark Cox <email@hidden>)

  • Prev by Date: Re: 1.45 x 1 = 1.450000047683716 ? :: CurrencyConverter
  • Next by Date: Re: Breakpoint on @throw?
  • Previous by thread: Re: [NSString initWithData: encoding:]
  • Next by thread: Japanese characters appearing in my apps name?
  • Index(es):
    • Date
    • Thread