willfo
willfo

Reputation: 249

How to pass a variable from View Controller to App Delegate

I have a class within my AppDelegate.m file called PAEAudioHost which I am using to play audio, and I want to stop the audio file using a UIButton in my Detail:Controller.m file.

To stop and start the audio file you use the public member functions:

void (start)
void (stop)

I have tried the following code in the detail controller:

 P11AppDelegate* app =[[UIApplication sharedApplication] delegate];
    [app.host stop]

This produces an error stating: "Property 'host' not found on object of type 'DetailController *'"

Any ideas how I can achieve this?

Upvotes: 0

Views: 460

Answers (1)

Klevison
Klevison

Reputation: 3484

host (PAEAudioHost) is a public property insite your AppDelegate? So:

P11AppDelegate* app = [[UIApplication sharedApplication] delegate];
[app.host stop]

EDIT:

You should have a public property called host into AppDelegate.h:

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) PAEAudioHost *host;

Upvotes: 1

Related Questions