there is a clock

time = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: "upTimeLabel", userInfo: nil, repeats: true)

 } // скобка закрытия viewDidLoad = ? override func viewWillAppear(animated: Bool) { super.viewWillAppear(animated) upTimeLabel() } func upTimeLabel() { let formatter = NSDateFormatter() // formatter.timeStyle = .MediumStyle //староС Π²Ρ‹Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅... formatter.dateFormat = "HH:mm:ss" timeShow.text = formatter.stringFromDate(clock.currentTime) var soundClock = formatter.dateFormat switch soundClock { case "18 53 00" : let path = NSBundle.mainBundle().pathForResource("k_k0001", ofType: "mp3")! let url = NSURL(fileURLWithPath: path) do { let sound = try AVAudioPlayer(contentsOfURL: url) self.soundClock = sound // soundClock.numberOfLoops = -1 sound.play() } catch { // couldn't load file :( } // скобка закрытия ΠΏΠ»Π΅Π΅Ρ€Π° = do... default : let path = NSBundle.mainBundle().pathForResource("soundAvtomat", ofType: "mp3")! let url = NSURL(fileURLWithPath: path) do { let sound = try AVAudioPlayer(contentsOfURL: url) self.soundClock = sound // soundClock.numberOfLoops = -1 sound.play() } catch { // couldn't load file :( } // скобка закрытия ΠΏΠ»Π΅Π΅Ρ€Π° // ) скобка закрытия case... } //скобка switch 

and so on ... you need to build in your sound every hour ... by default everything works out, (it means it lives ...) but case doesn’t grasp in the symbolical (OS no) - tried to change the format in the symbol - commas and: but not at all ... if to substitute in Int = OSH

  • can you normally write something you need to do and what does not work? what is glue sound? - Max Mikheyenko

1 answer 1

Your case with spaces

  case "18 53 00" 

In this case, you pass in a switch soundClock , which is var soundClock = formatter.dateFormat , and this is just "HH:mm:ss" .

First, transfer the formatted time, not the formatter . Secondly, make the correct case .

  • the question was resolved by = var soundClock: String! = timeShow.text and case = "18:53:00" - all scribbled .... thanks ... - user198638
  • not for a long time the bird danced ... sound sounds exactly as much as the timer allows ... (1 second) then everything, including the case, restarts ... if you throw the switch out of the timer, you need a declaration ... tried different options from AVAudioPlayer ( duration, timeInterval ...) = 0, substituted on case: func kk0012 (), (instead of everything that was there before) that I took out of the clock ... the sound starts the same way as before = 1 second and no longer wants ... anyway, the duration is reset by case =? thoughts ended ... @VAndrJ - user198638