Razvan Julian Razvan Julian - 1 year ago 52
Swift Question

How to fix: Type 'String' does not conform to protocol 'SequenceType' in Swift

I have a simple Label Text Animation in Swift.
And I got the following error:

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

Below there are some of my codes:


import UIKit

func setTextWithTypeAnimation(inputText: String, interval: NSTimeInterval, label: UILabel) {

label.text = ""

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0)) {

for character in inputText { // 1

dispatch_async(dispatch_get_main_queue()) {

label.text = label.text! + String(character)







import UIKit

class ViewController: UIViewController {

@IBOutlet var label: UILabel!

override func viewDidLoad() {

setTextWithTypeAnimation("This is very cool", interval: 0.13, label: label)


override func didReceiveMemoryWarning() {
// Dispose of any resources that can be recreated.


// 1
is the line with the error to the string:

Also, do you know a way for each character to have a different color?

I hope you could help me!
Thank you in advance!

Answer Source

Instead of doing for character in inputText {} you should do

for character in inputText.characters {}