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?
Best Answer
Swift 4 introduced changes on string API.
You can just use
!stringValue.isEmpty
instead ofstringValue.characters.count > 0
for more information you get the sample from here
for e.g