Illegal NSTableView data source with Hillegass Code

Discussion in 'Mac Programming' started by duggram, Jul 1, 2009.

  1. duggram macrumors 6502


    Apr 17, 2008
    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:eek: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:

    #import "AppController.h"
    @implementation AppController
    - (id)init
    	[super 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
    	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);
    	[speechSynth startSpeakingString:string];
    	NSLog(@"Have start to say: %@", string);
    	[stopButton setEnabled:YES];
    	[startButton setEnabled:NO];
    - (IBAction) stopIt:(id)sender
    	[speechSynth stopSpeaking];
    	[stopButton setEnabled:NO];
    	[startButton setEnabled:YES];
    - (int)numberOfRowsInTableview:(NSTableView *)tv 
    	return [voiceList count];
    -(id)tableView:(NSTableView *)tv
    		objectValueForTableColumn:(NSTableColumn *)tableColumn
    	NSString *v = [voiceList objectAtIndex:row];
    	NSDictionary *dict = [NSSpeechSynthesizer attributesForVoice:v];
    	return [dict objectForKey:NSVoiceName];
    	//return v;

    #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;
  2. kainjow Moderator emeritus


    Jun 15, 2000
  3. duggram thread starter macrumors 6502


    Apr 17, 2008
    I am giantly impressed with Aaron Hillegass. Late yesterday I posted this thread here, sent Aaron a message through his Web site, and went to bed. Soon after that Aaron sent me a message with the solution. Of course I'm embarrassed. But I'm also thankful that Aaron is so good to do what he did. It's been a long time (8+ yrs) since I've done any programming. I just don't have my ways back yet.

    Thank you Aaron for taking the time, and thank you kainjow too,

Share This Page