Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4556010
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:18:23+00:00 2026-05-21T17:18:23+00:00

I have looked at the other questions like this but cannot find help. When

  • 0

I have looked at the other questions like this but cannot find help. When I press a button thats supposed to play a sound the app crashes. Here is the debugging console:

The Debugger has exited with status 0.
[Session started at 2011-04-18 18:07:56 +0800.]
GNU gdb 6.3.50-20050815 (Apple version gdb-1515) (Sat Jan 15 08:33:48 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for details.
This GDB was configured as “x86_64-apple-darwin”.sharedlibrary apply-load-rules all
Attaching to process 3814.
Program received signal: “EXC_BAD_ACCESS”.
(gdb)

That was the debugger console.

Here is my coding:

AppDelegate.h

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>


@interface MathAppDelegate : NSObject <UIApplicationDelegate> {
    AVAudioPlayer* sound;
    UIWindow *window;
    UINavigationController *navigationController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;

@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;

-(IBAction)play;

@end

AppDelegate.m

#import "MathAppDelegate.h"
#import "MainMenuViewController.h"

@implementation MathAppDelegate
@synthesize window;

-(IBAction)play {
    NSString *path = [[NSBundle mainBundle] pathForResource:@"M1" ofType:@"aif"];
    AVAudioPlayer *sound = [[AVAudioPlayer alloc] initWithContentsOfURL: [NSURL fileURLWithPath:path] error:NULL];
    sound.delegate = self;    ("I get an error here saying 'Local declaration of 'sound' hides instance variable") and ("Class 'MathAppDelegate' does not implement the AVAudioPlayerDelegate' protocol")
    [sound play];  ("I get an error here saying 'Local declaration of 'sound' hides instance variable'")
}

I have connected the button to the action in the Interface Builder. What makes me feel like this has messed up is that I had to drag the app delegate object from the mainwindow.xib to the mainmenuviewcontroller.xib because that was where I needed to put the button. It still connected though.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T17:18:24+00:00Added an answer on May 21, 2026 at 5:18 pm

    Easiest solution is to have your button actions point to actions available in objects in the same XIB. So you probably want to hook the play action in your main menu controller point to the file’s owner, in this case probably your MainMenuViewController object. I would just move the play action and related code to that file.

    The application delegate was an object controller in your MainWindow.xib and configured as a delegate for the window in that same file. Since you moved it to another xib, the delegate of your window now points to a non existing object. This might explain the crash.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have looked for similar questions, but could find none other than the difference
so i have looked at a couple other questions like this and from what
I looked at other questions regarding this problem and tried their solutions, but it
I have looked at several other questions but I can't seem to figure any
I would like to mention before continuing that I have looked at other questions
Have looked quite hard for this answer but having no luck. I have 3
I've been trying this for a bit now and have looked at other answers
I looked at some other SO questions, didn't find anything that solved my problem...
I have looked within Stack Overflow and online elsewhere but can't find an answer
This may be an easy one. I looked through previous questions (and other places

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.