搜索具有 nsmutablearray 内容的字符串
这可能是一个快速而简单的问题,但是我如何能够使用 nsmutablearray 的内容(即字符串)搜索字符串。所以我有 NSString *blah = @"djfald.ji"
。我有 nsmutablearray 填充了不同的扩展名,我想搜索字符串 blah 以查看是否有任何扩展名匹配。我曾经使用 -[NSRange rangeOfString:]
但这不适用于数组。
谢谢,
凯文
This is probably a quick and easy question, but how would I be able to search a string with the contents of a nsmutablearray which are strings. So I have the NSString *blah = @"djfald.ji"
. I have the nsmutablearray filled with different extensions and I want to search the string blah to see if any of the extensions have a match. I used to use -[NSRange rangeOfString:]
but that doesn't work with arrays.
Thanks,
Kevin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您确实正在处理路径扩展,那么最好以相反的方式进行处理。像这样的东西:
If you really are dealing with path extensions, it's probably better to approach this the other way round. Something like:
只需使用块:
或者只需使用枚举循环遍历数组。
Simply use a block:
Or simply loop through the array with an enumeration.