AVSpeechSynthsesizer on timer

If a switch is turned on, text-to-word spoken every x seconds. The switch is on the first view controller, and the speech occurs after a segue to the second view controller.

Code in the first view controller:

@IBAction func speakwords(sender: AnyObject) {
        NSNotificationCenter.defaultCenter().postNotificationName("speaknotif", object: speakwords)

Code in the second view controller:

verride func viewDidLoad() {
NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("talk:"), name: "speaknotif", object: self.view.window)

func talk(notification: NSNotification){guard let count = notification.object else {return}
        if Bool(TYPE_BOOL as! NSO) = "true"{

        let speechsynth = AVSpeechSynthesizer()}


In your case, Notification Center was useless. Because you are calling post method before adding observer for that notification. So notification concept won't work there.

Instead of this, just set one Bool like "isSwitchSelected". And pass that value to next vc, check if the value is yes, then call func talk method.

Need Your Help

grep using a character vector with multiple patterns

r regex

I am trying to use grep to test whether a vector of strings are present in an another vector or not, and to output the values that are present (the matching patterns).

iterating through json in javascript

javascript json iteration

I have an iteration trough json that I cannot make to work.