Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type 'String' does not conform to protocol 'Sequence'

Tags:

string

swift

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?

picture

like image 445
user7341005 Avatar asked May 24 '26 01:05

user7341005


1 Answers

let flowers = "Flowers 💐"
for c in flowers.characters {
    print(c)
}

is valid.

like image 176
mrabins Avatar answered May 27 '26 04:05

mrabins



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!