• 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: cString deprecated!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cString deprecated!


  • Subject: Re: cString deprecated!
  • From: Julien Jalon <email@hidden>
  • Date: Tue, 3 Sep 2002 23:39:04 +0200

Le mardi, 3 sep 2002, ` 18:20 Europe/Paris, Matt Neuburg a icrit :
- (const char*) myCString: (int) encoding {
return [[[self stringByAppendingString:
@"\0"] dataUsingEncoding: encoding
allowLossyConversion:YES]
bytes];
}

Note that although the docs are not so clear about this, you must also
write your own stringWithCString, because this makes the same bad
assumption. Here is an example:

+ (id) myStringWithCString: (const char *) cString encoding: (int) encoding{
NSData* d = [NSData dataWithBytesNoCopy:(void*)cString
length:strlen(cString) freeWhenDone:NO];
return [[[NSString alloc] initWithData: d encoding: encoding] autorelease];
}


I think you should look at my NSString category :
http://softrak.stepwise.com/display?pkg=3033&os=20

--
Julien Jalon
<http://www.julien-jalon.org/>
<http://nuxeo.com/>
_______________________________________________
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.

References: 
 >Re: cString deprecated! (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: The macs serial number (clearer)
  • Next by Date: Re: Bad Assembly Code Generation?[solved]
  • Previous by thread: Re: cString deprecated!
  • Next by thread: Re: cString deprecated!
  • Index(es):
    • Date
    • Thread