gpt4 book ai didi

iphone - NSArray compontentsSeperatedByString 返回无法识别的选择器

转载 作者:行者123 更新时间:2023-12-03 17:42:37 26 4
gpt4 key购买 nike

我有一个包含三个单词的字符串,由管道 ( | ) 分隔我想将它们分成三个单独的字符串

NSArray *bits = [word.variants componentsSeparatedByString: @"|"];

NSLog(@"BITS: %@", bits);

这将返回一个无法识别的选择器。我在项目的其他区域使用了这行代码,并且运行良好。但不是这个。

-[__NSArrayI componentsSeparatedByString:]: unrecognized selector sent to instance 0x6dbfa80

有什么想法吗?

最佳答案

我也有同样的问题,而我的字符串有这么多白色字符、换行符,所以我无能为力,但最后我得到了如下解决方案:

 NSString *artwork = [currentURL valueForKey:@"artwork_large"]; 
//i got the string artwork ,which is fetch from json.

[smg addObject:artwork];
// add this string to 0th index of an array name:smg


NSSet *setObj1 = [NSSet setWithArray:smg];
//make the nsset for my array (named :smg)

NSString *pictureName = [[setObj1 allObjects] componentsJoinedByString:@","];
//make the string from all the sets joined by ","


picArray = [pictureName componentsSeparatedByString:@","];
//now its time for normal operation means makes the array (name: picArray) from string by componenet separatedbystring method

这样我现在就得到了我们可以控制的完美数组

关于iphone - NSArray compontentsSeperatedByString 返回无法识别的选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8743246/

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