ios - Pausing AvAudioPlayer from another view controller returns EXC_BAD_ACCESS Swift -


i've page-based application root view controller has button suposed pause avaudioplayer in data view controller. take granted know how root , data view controller work. mine looks this.

when i'm pressing button exc_bad_access. when i'm pausing button have on data view controller it's working fine without crash. i've tried:

• add pause code in function , call function

var dataview = self.storyboard?.instantiateviewcontrollerwithidentifier("dataviewcontroller") as! dataviewcontroller dataview.pause() 

dataviewcontroller

func pause() {     player.pause() } 

• calling function in dataview calls function pauses player

• tried call with

dataviewcontroller().player.pause() 

• tried call player.prepareforplay() before player.pause

and of them gives me same error. can because rootviewcontroller doesn't have permission edit player in dataviewcontroller?

this code:

dataviewcontroller().player.pause() 

creates new instance of dataviewcontroller. new instance doesn't have sound player. don't that. need way pointer existing instance of dataviewcontroller.

by way, should follow swift naming convention of naming classes , types starting upper-case letter. class name should dataviewcontroller.


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -