1
自從最近3到4個月(當沒有iOS 6的標誌)時,我正在開發計時器應用程序,但由於某些問題無法完成。現在自iOS 6的出現..我在我的代碼中出現錯誤。我最近下載了xcode 4.5和iOS 6 SDK(在其中)。現在,當我運行該應用程序。它在不同的場合崩潰。啓動時有時會崩潰。有時根本沒有崩潰。 有時會給我SGBRT錯誤。有時會出現Bad_exc錯誤(內存錯誤)。我不知道如何處理這個問題。我已經下載了iOS 5.1模擬器,並在那時運行應用程序。根本沒有崩潰,但當我在iOS 6模擬器上運行應用程序。重擊!它立即崩潰。 我非常需要指導。任何經歷過相同錯誤並且排除故障的人都請幫助我。 在此先感謝 法赫德。 - P.S.我添加了斷點來檢測錯誤,並且我只能捕捉到一個,但無法理解爲什麼出現此錯誤。下面是代碼:Xcode 4.5在iOS 5應用程序中導致錯誤
-(void) playAppSound:(NSString *) fName withExt:(NSString *) ext{
NSString *path = [[NSBundle mainBundle] pathForResource : fName ofType :ext];
if ([[NSFileManager defaultManager] fileExistsAtPath : path])
{
NSURL *pathURL = [[NSBundle mainBundle] URLForResource:fName withExtension:ext];
// Instantiates the AVAudioPlayer object, initializing it with the sound
if(self.appSoundPlayer)
{
if([self.appSoundPlayer isPlaying])
{
[self.appSoundPlayer stop];
[self.appSoundPlayer release];
}
}
//Thread breaks down in the next line self. appSoundPlayer...
self.appSoundPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: pathURL error: nil] ;
//self.appSoundPlayer.numberOfLoops = 1;
[appSoundPlayer setDelegate:self];
[appSoundPlayer prepareToPlay];
//[appSoundPlayer setVolume:1.0];
[appSoundPlayer play];
}
else{
// NSLog(@"error, file not found: %@", path);
}
}