Concatenating Strings in Obj C

Posted by eco_bach on Stack Overflow See other posts from Stack Overflow or by eco_bach
Published on 2010-06-12T20:01:23Z Indexed on 2010/06/12 20:02 UTC
Read the original article Hit count: 191

Hi
It seems that Objective C jumps thru hoops to make seemingly simple tasks extremely difficult.

I simply need to create a sequence of strings, image1.jpg, image2.jpg, etc etc

ie in a loop var imgString:String='image'+i+'.jpg;

I assume a best practice is to use a NSMutableString with appendString method?

What am I doing wrong??

NSMutableString *imgString;

    for(int i=1;i<=NUMIMAGES;i++){
    imgString.appendString(@"image"+i+@".jpg");
}

I get the following error

error: request for member 'appendString' in something not a structure or union

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about best-practices