_tableView setEnabled problem


#1

On page 111

[_speakButton setEnabled:NO]; (page 104)

has changed to

[_startButton setEnabled:NO];

Also I’m getting an error 'Receiver type ‘NSTableColumn’ for instance message does not declare a method with selector 'setEnabled’
at [_tableView setEnabled:YES]; and below [_tableView setEnabled:NO];

On page 109, there is the sentence ‘Also, set the SpeakLineAppDelegate to be the delegate of the table view’. I’m not sure that I’ve done this step correctly. The Connection Inspector shows

Outlets:
dataSource — x Speak Line App…
delegate — x Speak Line App…


#2

Looks like I set the link to the TableColumn and not the TableView.

@property (weak) IBOutlet NSTableColumn *theTableView;
instead of
@property (weak) IBOutlet NSTableView *theTableView;

I thought the name tableView might be a problem and changed it to theTableView. The enable/disable isn’t working yet but might be a problem with the name.


#3

I added the respondsToSelector method to SpeakLineAppDelegate (not AppController.m) and noticed

SpeakLine[7592:707] respondsToSelector:speechSynthesizer:didEncounterErrorAtIndex:ofString:message:

Is there a problem?

Also saw
SpeakLine[7592:707] respondsToSelector:applicationDockMenu:
other lines seem to be related to the SpeakLine application


#4

Good catch on _speakButton – that will be added to the errata. The dataSource and delegate bindings look correct.

[quote=“pharmpk”]Looks like I set the link to the TableColumn and not the TableView.

@property (weak) IBOutlet NSTableColumn *theTableView;
instead of
@property (weak) IBOutlet NSTableView *theTableView;

I thought the name tableView might be a problem and changed it to theTableView. The enable/disable isn’t working yet but might be a problem with the name.[/quote]

The outlet name “tableView” should be fine. If you change the name type, make sure that you make the new connection to the table view as well. Also, if you change the name make sure that there isn’t a stale connection from the table column to that non-existent outlet – it will crash.

Try logging the tableView outlet value (below), or use the debugger to be sure that your tableView outlet is being set to the right object. That should help you determine why the setEnabled: call isn’t working.

[quote=“pharmpk”]I added the respondsToSelector method to SpeakLineAppDelegate (not AppController.m) and noticed

SpeakLine[7592:707] respondsToSelector:speechSynthesizer:didEncounterErrorAtIndex:ofString:message:

Is there a problem?

Also saw
SpeakLine[7592:707] respondsToSelector:applicationDockMenu:
other lines seem to be related to the SpeakLine application[/quote]

I don’t understand what you mean by “added the respondsToSelector” method – do you mean you implemented it so you can print out what’s being passed to that method?


#5

I added the code at the top of page 114 to SpeakLineAppDelegate.m file and to see the printout of what was passed. I noted that it printed activity that seemed to be outside the scope of the SpeakLineAppDelegate. For example the line
SpeakLine[7592:707] respondsToSelector:applicationDockMenu:

Also, I noted what looked like an error, i.e. the line:
SpeakLine[7592:707] respondsToSelector:speechSynthesizer:didEncounterErrorAtIndex:ofString:message:


#6

Ah! No, this does not indicate a problem. What’s happening is that when you set a delegate relationship, many classes ‘scan’ the delegate using respondsToSelector: and then set flags in their instance variables to tell it whether or not the delegate responds to certain delegate methods. This allows it to operate more efficiently later on (in that it doesn’t have to ask the object if it responds to the selector every time it might want to call it).


#7

OK, thanks.


#8

Hi,

I just want to point out again that, as pharmpk has already stated, there is a small mistake on page 114, where it is suggested to add a method respondsToSelector to AppController.m, which should be SpeakLineAppDelegate.m.

Maybe that should be added to the errata too.

Otherwise, keep up the good work - it’s a very valuable book :wink:


#9

Thanks, spheenik. This item is in the errata.