私はバックグラウンド処理を行うためにここに、このガイドに従っ:バックグラウンド処理によりBAD ACCESSのクラッシュが発生しますか?
とバックグラウンド処理に置かれたコードの唯一の1行だった:
音= flite_text_to_wave([cleanString UTF8Stringを]、声);
しかし何らかの理由で私は不正なアクセス信号を受け取りました。
デバッグすると、その行でもクラッシュすることが示されます。これは私が今その部分で持っているコードです。これのほとんどはちょうどそれがすべて一緒にいたとき、/ 3
-(void)speakText:(NSString *)text //This is called by my app
{
cleanString = [NSMutableString stringWithString:@""];
if([text length] > 1)
{
int x = 0;
while (x < [text length])
{
unichar ch = [text characterAtIndex:x];
[cleanString appendFormat:@"%c", ch];
x++;
}
}
if(cleanString == nil)
{ // string is empty
cleanString = [NSMutableString stringWithString:@""];
}
//The next line i've put in from the link
[self performSelectorInBackground:@selector(backgroundTextToSpeech) withObject:nil];
}
-(void)backgroundTextToSpeech {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
//The following line is the one it crashes on
sound = flite_text_to_wave([cleanString UTF8String], voice);
[self performSelectorOnMainThread:@selector(backToForegroundTextToSpeech) withObject:nil waitUntilDone:YES];
[pool release];
}
-(void)backToForegroundTextToSpeech {
NSArray *filePaths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
NSString *recordingDirectory = [filePaths objectAtIndex: 0];
// Pick a file name
tempFilePath = [NSString stringWithFormat: @"%@/%s", recordingDirectory, "temp.wav"];
// save wave to disk
char *path;
path = (char*)[tempFilePath UTF8String];
cst_wave_save_riff(sound, path);
// Play the sound back.
NSError *err;
[audioPlayer stop];
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:tempFilePath] error:&err];
[audioPlayer setDelegate:self];
[audioPlayer prepareToPlay];
}
に私が間違って何をやったか任意のアイデアを分離していない、前に何の問題もなかったsfosterプロジェクトから口論のものをデフォルトされていることに注意してくださいこの出来事をやめるために私は何ができますか?
EDIT:以下掲載いくつかのコードでそれを円形に変化した後、デバッガの絵:あなたはどのように自動解放作品を理解していない
申し訳ありませんがわかりません。私が言ったように、そのコードの大部分はfliteからインポートされていると言っていたので、私がリリースした唯一のビットはプールであり、それについては私が投稿したリンクのガイドが示したとおりでした。 – Andrew