If I want to print every characters in a string, I can use following code:
let flowers = "Flowers 💐"
for c in flowers.characters {
print(c)
}
But recently, when I used the following code from apple's API Link of API and got an error(which said: Type 'String' does not conform to protocol 'Sequence'), is api wrong or there something else I ignored?
let flowers = "Flowers 💐"
for c in flowers.characters {
print(c)
}
is valid.
是的,API是错误的,你应该添加.characters
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.