Hey there! I have got an error when I try to run my xcode swift playground

Here's what it says:

error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0).

The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation.


Here's my code:


import UIKit

import PlaygroundSupport

import AVFoundation

class ViewController: UIViewController {


override func viewWillAppear(_ animated: Bool) {

super.viewWillAppear(true)

let view = UIView()

view.backgroundColor = UIColor.white

let label = UILabel()

label.text = ""

view.addSubview(label)

self.view = view

/

}


}

PlaygroundPage.current.liveView = ViewController() //error


in my sources folder there is one file:



import Foundation

import UIKit

extension UILabel {

func animate(newText: String) {

for everyChar in newText {

if self.text != "" {

self.text = self.text! + String(everyChar)

sleep(4)

}else {

self.text = String(everyChar)

sleep(4)

}

}

}

}



Please tell the error.


Thanks in advance

Regards

Replies

Oh I forgot to copy one line after the self.view = view (where the slash is )



label.animate(newText: "Swift")

For hints on searching on common errors, code formatting and comment edits etc., pls. see: For Best Results - Read the Label thanks and good luck