2013-10-25 36 views
-5

這是錯誤的Xcode shoy我:應用程序崩潰與無法識別的選擇發送到實例

2013年10月25日11:43:35.059中國跳棋[7220:C07] - [HomeViewController 玩法:]:無法識別選擇發送到實例0x8a2de20 2013年10月25日 11:43:35.062中國跳棋[7220:C07] *終止應用程序由於 未捕獲的異常 'NSInvalidArgumentException',原因: 「 - [HomeViewController播放:]:無法識別的選擇發送到實例 0x8a2de20'

*第一擲調用堆棧:

(0x1af7012 0x14a4e7e 0x1b824bd 0x1ae6bbc 0x1ae694e 0xeed2c0 0x1ab6376 0x1ab5e06 0x1a9da82 0x1a9cf44 0x1a9ce1b 0x278b7e3 0x278b668 0x3e8ffc 0x28fd 0x2def725爲0x1)的libC++ abi.dylib:終止叫做拋出 異常(LLDB)0x8a2de20

我真的裝盤把一個背景聲音對我的應用程序,我把sourece代碼

-(IBAction)play 
{ 
    NSString *soundFilePath =[[NSBundle mainBundle] pathForResource: @"larga"ofType: @"mp3"]; 
    NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath]; 
    AVAudioPlayer *newPlayer =[[AVAudioPlayer alloc] initWithContentsOfURL: fileURL error: Nil]; 

    self.player = newPlayer; 

    [self.player prepareToPlay]; 
    [self.player setDelegate: self]; 
    [self.player play]; 
    [NSTimer scheduledTimerWithTimeInterval: 30 target: self 
            selector: @selector(play:) userInfo: nil repeats: YES]; 
} 

    - (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    ............................. 
    ............................... 

     [self.player play]; 
} 
+0

你做了什麼:( –

+0

編輯您的代碼,以便它看起來不錯 – Arbitur

+0

無需使用的NSTimer在播放聲音。 。環有一個屬性self.player.numberOfLoops = -1; –

回答

9

有了這個:

[NSTimer scheduledTimerWithTimeInterval: 30 target: self 
           selector: @selector(play:) userInfo: nil repeats: YES]; 

要調用您的視圖控制器上的方法打,那個方法不存在。

嘗試創建它(刪除:從玩法:在選擇):

[NSTimer scheduledTimerWithTimeInterval: 30 target: self 
           selector: @selector(play) userInfo: nil repeats: YES]; 

-(void)play 
{ 
    [self.player play]; 
} 
+0

什麼是計時的需要 –

+1

我不想問,我只固定崩潰 –

+2

刪除NSTimer也將修復崩潰:P –

相關問題