tags:

views:

34

answers:

1

hi guys,

so I have this variable, AVAudioPlayer *introSound; , in my delegate named AppDelegate.h.

it plays continuously during first load.

[introSound stop];


What I want to do is stop it from a separate controller, firstController.m.

I tried

[AppDelegate.introSound stop];

but it threw an error saying:

error: expected ':' before '.' token

A: 

I assume you mean a compiler error? AppDelegate refers to the class, not to the instance of the class that is your application delegate. To get that from anywhere, do this:

AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
[appDelegate.introSound stop];

You also need to make sure that introSound is a property, not just an instance variable of AppDelegate.

Peter DeWeese
Thanks! This did the trick. Though I added it as: AppDelegate*appDelegate = (AppDelegate*) [[UIApplication sharedApplication] delegate];much appreciated!
TRF