Xcode异常断点始终暂停属性

时间:2013-06-17 14:23:58

标签: ios objective-c xcode debugging breakpoints

这让我疯了很长时间。我正在使用Xcode 4.6,但这已经发生在几个版本中。当我打开断点并添加异常断点时,它总是在我正在设置音频播放器的一行代码上暂停。我以相同的方式在前后设置了一些,但它只停留在那个上。

以下是我正在使用的代码:

    [[AVAudioSession sharedInstance] setDelegate: self];
    [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryAmbient error: nil];

    NSError *activationError = nil;
    [[AVAudioSession sharedInstance] setActive: YES error: &activationError];

    self.playedSongs = [NSMutableSet setWithCapacity:9];
    [self loadSettingsFromFile];
    NSURL *sfxPath = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"Snap.aiff" ofType:nil]];
    self.snapSfx = [[[AVAudioPlayer alloc]initWithContentsOfURL:sfxPath error:nil]autorelease];
    self.snapSfx.volume = 1.f;

    NSURL *fireworksPath;
    if ([OriginalIPadChecker isNotiPadOriginal]) {
        fireworksPath = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"FireworksSFX.mp3" ofType:nil]];
   }
    else{
        fireworksPath = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"NoFireworksSFX.mp3" ofType:nil]];
    }
    self.fireWorksSfx = [[[AVAudioPlayer alloc]initWithContentsOfURL:fireworksPath error:nil]autorelease];
    self.fireWorksSfx.volume = 1.f;

    NSURL *poofPath = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"Remove Poof.mp3" ofType:nil]];

    //The line below is the one that it pauses on
    self.removePoof = [[[AVAudioPlayer alloc]initWithContentsOfURL:poofPath error:nil]autorelease];
    self.removePoof.volume = 1.f;

    NSURL *newHighScorePath = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"New High Score.mp3" ofType:nil]];
    self.theNewHighScore = [[[AVAudioPlayer alloc]initWithContentsOfURL:newHighScorePath error:nil]autorelease];
    self.theNewHighScore.volume = 1.f;

    NSURL *badgeInTrophyPath = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"Badge In Trophy.aiff" ofType:nil]];
    self.badgeInTrophy = [[[AVAudioPlayer alloc]initWithContentsOfURL:badgeInTrophyPath error:nil]autorelease];
    self.badgeInTrophy.volume = 1.f;

    NSURL *dingPath = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"Ding.aif" ofType:nil]];
    self.ding = [[[AVAudioPlayer alloc]initWithContentsOfURL:dingPath error:nil]autorelease];
    self.ding.volume = 1.f;

应用程序不会崩溃并且声音播放正常,但调试器总是暂停一行 - 即使我将其移动到其他地方,它仍会暂停。我可以继续执行并且它工作得很好,但这确实让我感到烦恼。

我不明白为什么它会暂停。有什么想法吗?

2 个答案:

答案 0 :(得分:3)

正如Xcode stops on prepareToPlay的评论中所解释的那样,断点的原因是你在All'上设置了类型'异常的通用断点。它响应c ++库触发的信号。最好使用" Objective-c"异常断点,它将保护这种情况。

答案 1 :(得分:2)

尝试此操作并更新停止位置的问题(如果停止):

AVAudioPlayer *foo;
NSError *error = nil;
assert(poofPath);

foo = [AVAudioPlayer alloc];
foo = [foo initWithContentsOfURL:poofPath error:&error];
assert(foo);
[self setRemovePoof:foo];
[foo release];

如果断言开始,这可能是Apple的问题。不幸的是,有些Apple内部框架使用try / catch,它们会触发断点。它不常见,但确实发生了。

如果最终foo不是nil并且错误也是nil,那么你能做的最好就是在bugreporter.apple.com上输入错误报告(这会很棒)。另外,你看过poofPath - URL是否有可能返回原始音频以外的任何内容?

我的猜测是Apple试图打开并处理该文件,它会获得一个内部异常,因为该文件存在“奇怪”或异常。然后框架执行额外的工作,并设法读取文件。所以你得到你的声音,但也是例外。拿一些常见类型的mp3并将其放入你的应用程序包中,并尝试打开它。看看它(可能还有一些其他文件)是否给出了同样的错误。或者用声音创建一个演示项目并上传它(最后你可能需要在一个错误报告中将演示项目提交给Apple)。这些事情应该报告错误。

编辑:不幸的是有些Apple内部框架使用try / catch,它们会触发断点。然后,如前所述,一些后来的代码最终会弄清楚如何解码文件。

原始海报在评论中回应说这个特定文件是使用Audacity创建的,并且听说这些文件经常有解码问题。

相关问题