views:

77

answers:

2

Hi,

I am pretty new to iPhone programming.

I have a navBar with three views. I need to control audio from all of the views. I only want one audio stream to play at a time. I was thinking that it would be smart to let my AppDelegate have an instance of my audioplaying class and let the three other views use that instance to control the audio. My problem is that I don´t know how my views can use the audioplaying class in my AppDelegate.

Is this the best approach and if so, how? Is there a better way?

A: 

The cleanest way would probably be to implement a singleton that you could access from all your view controllers (e.g. [[MYAudioController sharedController] theAudio]). It's also possible to access it in your app delegate (e.g. [(MYAppDelegate *)[[UIApplication sharedApplication] delegate] theAudio], but I tend to think it's a bad idea to make view controllers dependent on the app delegate.

eman
A: 

You are right. I tried using a singleton. It worked! Thank you very much! :)

Are Refsdal