スレ番90の続き
@synthesize stopButton=_stopButton;、@synthesize speakButton =_speakButtonを追加しても同じ結果でした
AppDelegate.m
import "AppDelegate.h"
@interface AppDelegate ()
@property (weak) IBOutlet NSWindow *window;
@end
@implementation AppDelegate
@synthesize window = _window;
@synthesize textField = _textField;
-(id)init {
self = [super init];
if (self) {
_speechSynth = [[NSSpeechSynthesizer alloc]initWithVoice:nil];
[_speechSynth setDelegate:self];}
return self;}
- (IBAction)stopIt:(id)sender {
[_speechSynth stopSpeaking];}
- (IBAction)sayIt:(id)sender {
NSString *string = [_textField stringValue];
if ([string length] == 0) {
return; }
[_speechSynth startSpeakingString:string];
NSLog(@"Have started to say:%@",string);
[ stopButton setEnabled:YES];
[ speakButton setEnnabled:NO];}
-(void)speechSynthesizer:(NSSpeechSynthesizer*)sender
didFinishSpeaking:(BOOL)finishedSpeaking{
NSLog(@"finishedSpeaking = %d",finishedSpeaking);
[ stopButton setEnabled:NO];
[ speakButton setEnabled:YES];}
@end