Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Shaun Kelly
Shaun Kelly
5,648 Points

My code is not right to play the sound it is saying Thread 1: breakpoint 1.2 on [introSoundFX play];

#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
@interface ViewController ()


@implementation ViewController {
    AVAudioPlayer *introSoundFX;

- (void)viewDidLoad {
    [super viewDidLoad];

    NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"Intro Soundtrack" ofType:@"mp3"];
    NSURL *soundURL = [NSURL fileURLWithPath:soundPath];
    introSoundFX = [[AVAudioPlayer alloc] initWithContentsOfURL:soundURL error:nil];


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    [introSoundFX play];

-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
     self.backgroundImageView.animationImages = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"1"],
                                                [UIImage imageNamed:@"2"],
                                                [UIImage imageNamed:@"3"],
                                                [UIImage imageNamed:@"4"],
                                                [UIImage imageNamed:@"5"],
                                                [UIImage imageNamed:@"6"],
                                                [UIImage imageNamed:@"7"],
                                                [UIImage imageNamed:@"8"],
                                                [UIImage imageNamed:@"9"],
                                                [UIImage imageNamed:@"10"],
                                                [UIImage imageNamed:@"11"],
                                                [UIImage imageNamed:@"12"],
                                                [UIImage imageNamed:@"13"],
                                                [UIImage imageNamed:@"14"],
                                                [UIImage imageNamed:@"15"],
                                                [UIImage imageNamed:@"16"],
                                                [UIImage imageNamed:@"17"],
                                                [UIImage imageNamed:@"18"],
                                                [UIImage imageNamed:@"19"],
                                                [UIImage imageNamed:@"20"],
                                                [UIImage imageNamed:@"21"],
                                                [UIImage imageNamed:@"22"],
                                                [UIImage imageNamed:@"23"],
                                                [UIImage imageNamed:@"24"],
                                                [UIImage imageNamed:@"25"],
                                                [UIImage imageNamed:@"26"],
                                                [UIImage imageNamed:@"27"],
                                                [UIImage imageNamed:@"28"],
                                                [UIImage imageNamed:@"29"],
                                                [UIImage imageNamed:@"30"],
                                                [UIImage imageNamed:@"31"],
                                                [UIImage imageNamed:@"32"],
                                                [UIImage imageNamed:@"33"],
                                                [UIImage imageNamed:@"34"],
                                                [UIImage imageNamed:@"35"],
                                                [UIImage imageNamed:@"36"],
                                                [UIImage imageNamed:@"37"],
                                                [UIImage imageNamed:@"38"],
                                                [UIImage imageNamed:@"39"],
                                                [UIImage imageNamed:@"40"],
                                                [UIImage imageNamed:@"41"],
                                                [UIImage imageNamed:@"42"],
                                                [UIImage imageNamed:@"43"],
                                                [UIImage imageNamed:@"44"],
                                                [UIImage imageNamed:@"45"],
                                                [UIImage imageNamed:@"46"],
                                                [UIImage imageNamed:@"47"],
                                                [UIImage imageNamed:@"48"],
                                                [UIImage imageNamed:@"49"],
                                                [UIImage imageNamed:@"50"],
                                                [UIImage imageNamed:@"51"],
                                                [UIImage imageNamed:@"52"],
                                                [UIImage imageNamed:@"53"],
                                                [UIImage imageNamed:@"54"],
                                                [UIImage imageNamed:@"55"],
                                                [UIImage imageNamed:@"56"],
                                                [UIImage imageNamed:@"57"],
                                                [UIImage imageNamed:@"58"],
                                                [UIImage imageNamed:@"59"],
                                                [UIImage imageNamed:@"60"],
                                                [UIImage imageNamed:@"61"],
                                                [UIImage imageNamed:@"62"],
                                                [UIImage imageNamed:@"63"],
                                                [UIImage imageNamed:@"64"],
                                                [UIImage imageNamed:@"65"],
                                                [UIImage imageNamed:@"66"],
                                                [UIImage imageNamed:@"67"],
                                                [UIImage imageNamed:@"68"],
                                                [UIImage imageNamed:@"69"],
                                                [UIImage imageNamed:@"70"],
                                                [UIImage imageNamed:@"71"], nil];
    self.backgroundImageView.animationDuration = 3.0;
    self.backgroundImageView.animationRepeatCount = 1;

    [self.backgroundImageView startAnimating];

-(void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {