Shortcuts in Objective-C to concatenate NSStrings

前端 未结 30 2652
伪装坚强ぢ
伪装坚强ぢ 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条回答
  •  -上瘾入骨i
    2020-11-22 07:57

    NSString *myString = @"This";
    NSString *test = [myString stringByAppendingString:@" is just a test"];
    

    After a couple of years now with Objective C I think this is the best way to work with Objective C to achieve what you are trying to achieve.

    Start keying in "N" in your Xcode application and it autocompletes to "NSString". key in "str" and it autocompletes to "stringByAppendingString". So the keystrokes are quite limited.

    Once you get the hang of hitting the "@" key and tabbing the process of writing readable code no longer becomes a problem. It is just a matter of adapting.

提交回复
热议问题