Objective-c string appending causes exception

Posted by Dave C on Stack Overflow See other posts from Stack Overflow or by Dave C
Published on 2010-03-29T17:53:26Z Indexed on 2010/03/29 18:13 UTC
Read the original article Hit count: 507

Filed under:

Hello Everyone,

The following code is causing me some problems. The third line causes a program crash... it doesn't happen the first time I step through but somehow later on in the program. If I comment out that third line, the program runs smoothly.

NSString *myRequestString = @"text";
int i = 1;
myRequestString = [myRequestString stringByAppendingString:[NSString stringWithFormat: @"t=%d", i]];

That code causes this exception:

* -[CFString release]: message sent to deallocated instance 0xb4c43fe0

On a side note, can anyone tell me how to concatenate strings in objective-c like any other normal language... I can't believe that there is no concatenation operator.

Any and all help is greatly appreciated.

© Stack Overflow or respective owner

Related posts about objective-c