過去3〜4か月(iOS 6の兆候がなかったとき)からタイマーアプリケーションに取り組んでいますが、いくつかの問題のためにそれを完了できませんでした。iOS 6の登場以来、コードにエラーが発生しています。最近、xcode4.5とiOS6 SDK(その中)をダウンロードしました。今、私がアプリを実行すると。さまざまな場面でクラッシュします。起動時にクラッシュすることがあります。クラッシュがまったく発生しない場合もあります。時々SGBRTエラーが発生します。時々Bad_excエラー(メモリエラー)。これをどう扱うかわかりません。iOS 5.1シミュレーターをダウンロードし、アプリを実行するとその上にダウンロードしました。クラッシュはまったくありませんが、iOS6シミュレーターでアプリを実行したときです。ワム!すぐにクラッシュします。私は緊急に指導を必要としています。同じエラーが発生し、トラブルシューティングを行った方は、私も助けてください。AdvanceFahadに感謝します。-PS エラーを検出するためにブレークポイントを追加しました。1つしかキャッチできませんでしたが、なぜこのエラーが発生したのか理解できませんでした。コードは次のとおりです。
-(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);
}
}