警告:不推荐使用'characters':请直接使用String或Substring [英] warning: 'characters' is deprecated: Please use String or Substring directly
问题描述
我使用属性字符
执行/处理了很多字符串操作。
任何人对此次更新都有任何想法/信息?
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屋!