On 22 May 2014, at 12:54, Roland King <[email protected]> wrote:
> If you read the documentation for NSObject's
> performSelector:withObject:afterDelay it tells you which method you need to
> use to cancel it again, and it's not NSRunLoop's
> cancelPerformSelector:target:argument.
You are right. It is:
[ NSObject cancelPreviousPerformRequestsWithTarget: self selector:
@selector(resumeMusic) object: nil ];
Thanks a lot!
Gerriet.
>
> On 22 May, 2014, at 1:34 pm, Gerriet M. Denkmann <[email protected]> wrote:
>
>>
>> I have this code:
>>
>> - (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer
>> didFinishSpeechUtterance:(AVSpeechUtterance *)utterance
>> {
>> NSTimeInterval delay = 5;
>> NSLog(@"%s will resume music in %g sec.",__FUNCTION__, delay );
>> NSRunLoop *currentRunLoop = [ NSRunLoop currentRunLoop ]; //
>> not nil
>> [ currentRunLoop cancelPerformSelector: @selector(resumeMusic) target:
>> self argument: nil ];
>> [ self performSelector: @selector(resumeMusic) withObject: nil
>> afterDelay: delay ];
>> }
>>
>> - (void)resumeMusic
>> {
>> NSLog(@"%s Done!",__FUNCTION__ );
>> }
>>
>> When I speak something 7 times I get:
>>
>> 12:13:56.508 -[ContentViewController
>> speechSynthesizer:didFinishSpeechUtterance:] will resume music in 5 sec.
>> 12:13:57.724 -[ContentViewController
>> speechSynthesizer:didFinishSpeechUtterance:] will resume music in 5 sec.
>> 12:13:58.908 -[ContentViewController
>> speechSynthesizer:didFinishSpeechUtterance:] will resume music in 5 sec.
>> 12:14:00.115 -[ContentViewController
>> speechSynthesizer:didFinishSpeechUtterance:] will resume music in 5 sec.
>> 12:14:01.324 -[ContentViewController
>> speechSynthesizer:didFinishSpeechUtterance:] will resume music in 5 sec.
>> 12:14:01.527 -[ContentViewController resumeMusic] Done!
>> 12:14:02.520 -[ContentViewController
>> speechSynthesizer:didFinishSpeechUtterance:] will resume music in 5 sec.
>> 12:14:02.730 -[ContentViewController resumeMusic] Done!
>> 12:14:03.700 -[ContentViewController
>> speechSynthesizer:didFinishSpeechUtterance:] will resume music in 5 sec.
>> 12:14:03.929 -[ContentViewController resumeMusic] Done!
>> 12:14:05.126 -[ContentViewController resumeMusic] Done!
>> 12:14:06.339 -[ContentViewController resumeMusic] Done!
>> 12:14:07.523 -[ContentViewController resumeMusic] Done!
>> 12:14:08.705 -[ContentViewController resumeMusic] Done!
>>
>> But I would expect just to get *one* call to "resumeMusic" - 5 sec after the
>> last call to speechSynthesizer:didFinishSpeechUtterance:. Instead I get 7
>> calls - each 5 sec after the didFinishSpeechUtterance.
>> Seems that cancelPerformSelector has no effect at all.
>>
>> What am I doing wrong?
>> iOS 7.1.1
>>
>> Gerriet.
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]