1 Reply
      Latest reply on Sep 6, 2019 9:56 AM by takfromtoronto
      Jamal Jones Level 1 Level 1 (0 points)



        I've been trying to figure out why I keep geeting this error. I looked up code -42 and it means too many files open. The app works fine if I stay in the same view, but when I switch between views several times I get the error. Here is part of my code:



                    let A1path = NSBundle.mainBundle().pathForResource("A1", ofType: "wav")

                    let A1Url = NSURL(fileURLWithPath: A1path!)


                    do {

                        try A1Sound = AVAudioPlayer(contentsOfURL: A1Url)


                    } catch let err as NSError {





        func playA1() {

                A1Sound.currentTime = 0




        func stop() {


                if (A1Sound.playing){


                    A1Sound.currentTime = 0





        Can someone please help? Is there a way to close the files before I switch views or some other way to fix the error. I put the stop function int he menu IBAction function and it works fine.