- Joined
- Oct 7, 2009
- Messages
- 14
- Reaction score
- 0
- Points
- 1
- Location
- Singapore
Why is it that these two are correct:
and
The question is, why is it that you have to "alloc" when you are using the "initWithCString" function yet doesn't have to when you do stringWithFormat, I am puzzled because they BOTH returns a NSMutableString, so shouldn't they have similar initialization protocols ?
Yet when I try to:
It crashes ?
Likewise if I were to remove "alloc" from initWithCString.
Code:
NSMutableString* CombinedText = [NSMutableString stringWithFormat:@"%d %d %d",1,2,3];
and
Code:
NSMutableString* CombinedText = [[NSMutableString alloc] initWithCString:"String Data" ];
The question is, why is it that you have to "alloc" when you are using the "initWithCString" function yet doesn't have to when you do stringWithFormat, I am puzzled because they BOTH returns a NSMutableString, so shouldn't they have similar initialization protocols ?
Yet when I try to:
Code:
NSMutableString* CombinedText = [ [NSMutableString alloc] stringWithFormat:@"%d %d %d",1,2,3];
Likewise if I were to remove "alloc" from initWithCString.