Shortcuts in Objective-C to concatenate NSStrings

前端 未结 30 2936
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 07:03

Are there any shortcuts to (stringByAppendingString:) string concatenation in Objective-C, or shortcuts for working with NSString in general?

30条回答
  •  深忆病人
    2020-11-22 07:48

    When dealing with strings often I find it easier to make the source file ObjC++, then I can concatenate std::strings using the second method shown in the question.

    std::string stdstr = [nsstr UTF8String];
    
    //easier to read and more portable string manipulation goes here...
    
    NSString* nsstr = [NSString stringWithUTF8String:stdstr.c_str()];
    

提交回复
热议问题