gpt4 book ai didi

iphone - iphonesdk附加字符串问题

转载 作者:行者123 更新时间:2023-12-01 18:31:54 27 4
gpt4 key购买 nike

我有一个具有5个对象的nsmutablearray。

例如,如果它包含诸如苹果,猫,球,狗, Ant 之类的对象,我希望它们以逗号分隔,就像苹果,猫,球,狗, Ant 一样。请帮我解决一下这个。

编辑

publishingpost //nsmutable array contains all these object

-(ibaction)post
{
nsstring *str;
nsstring *str2 =@",";
for(int i = 0; i< [publishingpost count]; i++){
nsstring *str = [publishingpost objectAtIndex:i];
//append both str1, str2 to generate comma separated objects

}

最佳答案

使用- (NSString *)componentsJoinedByString:(NSString *)separator代替:

- (IBAction)post {
NSString * str = [publishingpost componentsJoinedByString:@", "];
}

关于iphone - iphonesdk附加字符串问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7981751/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com