How to join NSArray elements into an NSString?

后端 未结 3 1114
陌清茗
陌清茗 2021-01-29 23:18

Given an NSArray of NSStrings, is there a quick way to join them together into a single NSString (with a Separator)?

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-29 23:58

    NSArray * stuff = /* ... */;
    NSString * combinedStuff = [stuff componentsJoinedByString:@"separator"];
    

    This is the inverse of -[NSString componentsSeparatedByString:].

提交回复
热议问题