Re: Simple C Question
Re: Simple C Question
- Subject: Re: Simple C Question
- From: Ondra Cada <email@hidden>
- Date: Thu, 31 Jan 2002 16:17:28 +0100
Nathan,
>
>>>>> Nathan Day (ND) wrote at Fri, 1 Feb 2002 00:29:00 +1030:
ND> No I think he means [[NSString alloc] initWithFormat:@"%c", 'c' ]
It's possible. In that case I would personally prefer (presuming a char
variable instead of constant)
s=[[NSString alloc] initWith
Data:[NSData dataWithBytes:&c length:1] encoding:XXX];
though. The difference would be grave for char values over 128, and this way
you can control (by using the desired encoding for XXX) how it will behave.
Inicdentally, somewhat unrelated -- unless you would retain the thing
immediately otherwise, don't forget to autorelease objects made by alloc/init
lest they leak. The generally best pattern is to use autorelease
immediately, this way:
s=[[[NSString alloc] initWithWhatever....] autorelease]
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
2K Development: email@hidden
http://www.2kdevelopment.cz
private email@hidden
http://www.ocs.cz/oc