字符串字符可与iOS7兼容 [英] String characters count compatability with iOS7

查看:41
本文介绍了字符串字符可与iOS7兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将Swift 2用于支持iOS 7及更高版本的项目.

Using Swift 2, for a project that supports iOS 7 and later.

我正在尝试使用string.characters.count查找字符串中的字符数.但是,在快速帮助检查器中,它将可用性显示为 iOS(9.0和更高版本).

I am trying to find the count of characters in a String, by using string.characters.count. However in the Quick Help Inspector, it shows the availability as iOS (9.0 and later).

我在装有iOS 8.4的iPad上使用了此方法,但未出现任何错误,并为我提供了正确的字符串长度.

I have used this method on an iPad with iOS 8.4 installed on it and it did not give any errors, and gave me the correct length of the string.

如果我在安装了iOS 7的设备上使用它会发生什么?

What would happen if I were to use it on a device with iOS 7 installed on it?

推荐答案

快速帮助检查器提供了令人困惑的信息.

The Quick Help Inspector gives a confusing information.

string.characters.count依赖于 Swift版本,而不是iOS版本.

string.characters.count is dependent of the Swift version, not of the iOS version.

只要您使用的是Swift 2 +,string.characters.count就可以使用,而与操作系统无关.

As long as you're using Swift 2+, string.characters.count will be available, independently of the OS.

这篇关于字符串字符可与iOS7兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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