Objective-C Simplest way to create comma separated string from an array of objects

后端 未结 4 881
既然无缘
既然无缘 2021-01-30 19:49

So I have a nsmutablearray with a bunch of objects in it. I want to create a comma separated string of the id value of each object.

4条回答
  •  旧巷少年郎
    2021-01-30 20:24

    Create String from Array:

    -(NSString *)convertToCommaSeparatedFromArray:(NSArray*)array{
        return [array componentsJoinedByString:@","];
    }
    

    Create Array from String:

    -(NSArray *)convertToArrayFromCommaSeparated:(NSString*)string{
        return [string componentsSeparatedByString:@","];
    }
    

提交回复
热议问题