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?
I think that's because
stringWithFormat
returns an autorelease object while yourSomeString
is a global variable , soSomeString
is out of scope and released.try this :