Re: cString deprecated!
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.