[Biococoa-dev] unichar question
John Timmer
jtimmer at bellatlantic.net
Fri Aug 20 21:17:57 EDT 2004
> Hi,
>
> Anyone kniws why this gives a warning and how to fix it:
>
> symbolString = [[NSString alloc] initWithCharacters: [self symbol]
> length: 1];
>
> passing arg 1 of `initWithCharacters:length:' makes pointer from
> integer without a cast
>
Unichars are basically integers, so the signature of the method is wrong.
The flipside is that initWithCharacters expects a pointer to the characters,
so you have to use the & operand to convert it.
Try the following:
- (id)initWithSymbol:(unichar )aSymbol
{
if ( self = [super init] )
{
symbol = aSymbol;
symbolString = [[NSString alloc] initWithCharacters: &symbol
length: 1];
}
return self;
}
_______________________________________________
This mind intentionally left blank
More information about the Biococoa-dev
mailing list