Re: Problems with NSSpeechSynthesizer and Foundation tool?
Re: Problems with NSSpeechSynthesizer and Foundation tool?
- Subject: Re: Problems with NSSpeechSynthesizer and Foundation tool?
- From: Brian Ganninger <email@hidden>
- Date: Fri, 21 Jul 2006 20:39:51 -0500
Shouldn't it be...
if(iDidFinishSpeaking == YES)
because you want an equality test, not an assignment.
On Jul 21, 2006, at 8:12 PM, William Squires wrote:
Hi
I'm just trying to write a simple "Hello, world" program that
speaks the string rather than prints it. I made a simple class,
SpeakMe, to hold the 'guts' of the code. Here's the implementation
(SpeakMe.m):
#import <AppKit/NSSpeechSynthesizer.h>
#import "SpeakMe.h"
@implementation SpeakMe
-(id) init
{
NSLog(@"init\n");
self = [super init];
if (self)
{
iDidFinishSpeaking = NO;
speak = [[NSSpeechSynthesizer alloc] init];
[speak setDelegate:self];
}
return self;
}
-(void) doSpeak
{
NSLog(@"doSpeak\n");
NSString *text = @"Hello, Objective See";
[speak startSpeakingString:text];
for ( ;1 ; )
{
if (iDidFinishSpeaking = YES)
{
break;
}
}
}
-(void) speechSynthesizer:(NSSpeechSynthesizer *)sender
didFinishSpeaking:(BOOL)finished
{
NSLog(@"speechSynthesizer:didFinishSpeaking\n");
iDidFinishSpeaking = YES;
}
@end
In main.m, I set up a "SpeakMe *" as:
SpeakMe *speaker = [[SpeakMe alloc] init];
as one would expect. The NSLog shows it (the init method) gets
called. This sets up its speechSynthesizer:didFinishSpeaking
delegate (I hope...). I then call [speaker doSpeak]; in the next
line. It, too, fires - and NSLog shows that. But, shouldn't the
"deliberate infinite loop" keep code execution in the doSpeak
method until the delegate gets called to set the
'iDidFinishSpeaking' variable to YES? NSLog shows that the program
exits normally, so - clearly - the loop exited, but my output never
shows that the speechSynthesizer:didFinishSpeaking delegate got
called...
What's going on here?
William H Squires Jr
4400 Horizon Hill #4006
San Antonio, TX 78229
email@hiddenm <- remove the .nospam
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden