NSString 包含今天天气的温度
我试图检测温度是否在两组数字之间。即 70 - 79 如果在该范围内,则执行一个操作,在我的例子中设置一个特定的图像。我尝试过使用 rangeOfString:
但它只是在任何地方寻找一个数字。我需要它来查看 70 - 79 等 10 位数字区域的内部。
这是我的温度代码
NSString *Temperature = [NSString stringWithFormat:@"%d", Weather.Temperature];
我将如何获取字符串并在 0-9、10-19、20-29...60-69、70-79 等之间进行搜索?
如果有人可以向我指出苹果文档或其他内容,我将不胜感激。
谢谢
I'm trying to detect if the temperature is in-between two sets of numbers. i.e. 70 - 79
If its in that range, perform an action, in my case set a specific image. I've tried using rangeOfString:
but it was only looking for a number anywhere. I need it to look inside of a 10 digit area like 70 - 79.
Here is what I have for the temperature code
NSString *temperature = [NSString stringWithFormat:@"%d", weather.temperature];
How would I take the string and search in-between 0-9, 10-19, 20-29...60-69, 70-79 etc etc etc?
If anyone can point me to an apple document or something I would greatly appreciate it.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
既然你看起来以数字的形式存在,为什么不直接使用整数比较呢?
Since you appear to have it in the form of a number, why not just use integer comparison?