警告:不推荐使用'characters':请直接使用String或Substring [英] warning: 'characters' is deprecated: Please use String or Substring directly

查看:2671
本文介绍了警告:不推荐使用'characters':请直接使用String或Substring的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用属性字符执行/处理了很多字符串操作。



任何人对此次更新都有任何想法/信息?

解决方案

Swift 4引入了对字符串API的更改。

你可以使用!stringValue.isEmpty 而不是 stringValue.characters.count> 0



有关更多信息,请从这里



例如

  let edit =Summary
edit.count // 7


characters - an instance property of String, is deprecated from with Xcode 9.1

It was very useful to get a substring from String by using the characters property but now it has been deprecated and Xcode suggests to use substring. I've tried to check around SO questions and apple developer tutorials/guidelines for the same. But could not see any solution/alternate as suggested.

Here is warning message:

'characters' is deprecated: Please use String or Substring

I've so many string operations are performed/handled using property characters.

Anyone have any idea/info about this update?

解决方案

Swift 4 introduced changes on string API.
You can just use !stringValue.isEmpty instead of stringValue.characters.count > 0

for more information you get the sample from here

for e.g

let edit = "Summary"
edit.count   // 7

这篇关于警告:不推荐使用'characters':请直接使用String或Substring的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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