Pregunta

I declare an object in the beginning of M file as follows:

NSMutableString *SomeString;

And in a method I try to init it:

SomeString  = [NSMutableString stringWithFormat:@"%c",'0'];
NSMutableString *SomeOtherString = [NSMutableString stringWithFormat:@"%c",'0'];

When I debug after the above line, I see that SomeOtherString holds the string "0" but SomeString remains empty. What am I doing wrong?

¿Fue útil?

Solución

I think that's because stringWithFormat returns an autorelease object while your SomeString is a global variable , so SomeString is out of scope and released.

try this :

  SomeString  = [[NSMutableString alloc] initWithFormat:@"%c",'0'];
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top