ios nsrange char来自最后 [英] ios nsrange char from end

查看:86
本文介绍了ios nsrange char来自最后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我说我有:

这是一个例子 - 有些 - 破折号

NSRange 将使用`rangeOfString:@来获取 - 的第一个实例 - 但如果我只想要怎么办?最后一个?

NSRange will pick up the first instance of "-" with `rangeOfString:@"-" but what if I only want the last one?

我在中寻找与 lastIndexOf 类似的东西JS 谢谢!

I'm looking for something that works similar to lastIndexOf in JS. Thanks!

推荐答案

您可以传递给 [NSString rangeOfString:options:] 是NSBackwardsSearch(它会为您提供您正在查看的字符串中的最后一项)。

One of the options you can pass to [NSString rangeOfString: options:] is NSBackwardsSearch (which would give you the last item in the string you're looking at).

这篇关于ios nsrange char来自最后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆