How to append a string to NSMutableString

前端 未结 5 1755
自闭症患者
自闭症患者 2021-01-01 14:50

i\'m an absolute newbie with objective-c

with this code

NSMutableString *teststring;
[teststring appendString:@\"hey\"];
NSLog(teststring);
         


        
5条回答
  •  情书的邮戳
    2021-01-01 15:21

    You need to create the string first.

    NSMutableString *teststring = [[NSMutableString alloc]init];
    
    [teststring appendString:@"hey"];
    
    NSLog(teststring);
    

    Now, it will print.

提交回复
热议问题