I'm working on the Speakline exercise in the Hillegass Cocoa Programming book. In Chap. 6 up to page 105. When I run the app I get no values in the table. I do get this error message:
Illegal NSTableView data source (<AppController: 0x133dd0>). Must implement numberOfRowsInTableView: and tableView
bjectValueForTableColumn:row:
I have triple checked all code and IB maneuvers. I have checked his web page for errata, there is something unrelated for page 106.
I downloaded his solutions code. His solution Speakline_B looks nothing like the code in the book at this point.
I searched the Web for others that may have the same problem. No solutions.
Any advice on how I can get values to show up in the table? And, eliminate the error code?
BTW here's my code:
AppController.m
AppController.h
Illegal NSTableView data source (<AppController: 0x133dd0>). Must implement numberOfRowsInTableView: and tableView
I have triple checked all code and IB maneuvers. I have checked his web page for errata, there is something unrelated for page 106.
I downloaded his solutions code. His solution Speakline_B looks nothing like the code in the book at this point.
I searched the Web for others that may have the same problem. No solutions.
Any advice on how I can get values to show up in the table? And, eliminate the error code?
BTW here's my code:
AppController.m
Code:
#import "AppController.h"
@implementation AppController
- (id)init
{
[super init];
NSLog(@"init");
// create new instance of NSSpeechSynthesizer
speechSynth = [[NSSpeechSynthesizer alloc] initWithVoice:nil];
[speechSynth setDelegate:self];
[tableView setDelegate:self];
voiceList = [[NSSpeechSynthesizer availableVoices] retain];
return self;
}
- (void)speechSynthesizer:(NSSpeechSynthesizer *)sender
didFinishSpeaking:(BOOL)complete;
{
NSLog(@"complete = %d", complete);
}
- (IBAction)sayIt:(id)sender
{
NSString *string = [textField stringValue];
// Is the string zero-length
if ([string length] == 0) {
NSLog(@"string from %@ is of zero-length", textField);
return;
}
[speechSynth startSpeakingString:string];
NSLog(@"Have start to say: %@", string);
[stopButton setEnabled:YES];
[startButton setEnabled:NO];
}
- (IBAction) stopIt:(id)sender
{
NSLog(@"stopping");
[speechSynth stopSpeaking];
[stopButton setEnabled:NO];
[startButton setEnabled:YES];
}
- (int)numberOfRowsInTableview:(NSTableView *)tv
{
return [voiceList count];
}
-(id)tableView:(NSTableView *)tv
objectValueForTableColumn:(NSTableColumn *)tableColumn
row:(int)row
{
NSString *v = [voiceList objectAtIndex:row];
NSDictionary *dict = [NSSpeechSynthesizer attributesForVoice:v];
return [dict objectForKey:NSVoiceName];
//return v;
}
@end
AppController.h
Code:
#import <Cocoa/Cocoa.h>
@interface AppController : NSObject {
IBOutlet NSTextField *textField;
IBOutlet NSButton *stopButton;
IBOutlet NSButton *startButton;
IBOutlet NSTableView *tableView;
NSArray *voiceList;
NSSpeechSynthesizer *speechSynth;
}
- (IBAction)sayIt:(id)sender;
- (IBAction)stopIt:(id)sender;
@end