是否有可能通過選擇器停止循環進入方法調用? 我已經創建了一個停止所有運行過程的新方法,但是我不知道如何在audioloop方法中停止while循環。在方法中停止遞歸循環
這是我的代碼,請參閱:
-(id) init{
if((self=[super init])) {
// @property int isLoop;
self.isLoop = 1;
audioThread = [NSThread new];
[audioThread initWithTarget:self selector:@selector(audioLoop) object:nil];
[audioThread setThreadPriority:1];
[audioThread start];
}
}
// in this method i would stop while loop of audioLoop method
-(void)stopAllRunning{
self.isLoop = 0;
[audioThread cancel];
}
-(void) audioLoop{
while (isLoop) {
[_midiClock update];
}
}
更換'同時(真)'檢查對象的屬性。像'while(self.playAudio)',當你想停止它,'audioObj.playAudio = false;' – millimoose 2013-02-16 13:11:51
我,我已經更新我的代碼。現在是對的? – Jimmy 2013-02-16 13:47:26
你告訴我,你是一個可以測試它的人。 (也就是說,你不應該編輯你的問題來添加解決方案,這會讓那些想要提供完整答案的人感到困惑。) – millimoose 2013-02-16 14:17:42