Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL
Help

Chapter 6. Helper Objects > Edit AppController.m - Pg. 105

E DIT A PP C ONTROLLER . M 105 Edit AppController.m Implement the data source methods in AppController.m : - (int)numberOfRowsInTableView:(NSTableView *)tv { return [voiceList count]; } - (id)tableView:(NSTableView *)tv objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row { NSString *v = [voiceList objectAtIndex:row]; return v; } The identifer for a voice is a long string, such as com.apple.speech.synthe- sis.voice.Fred . If you want only the name Fred , replace the last method with this one: - (id)tableView:(NSTableView *)tv objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row { NSString *v = [voiceList objectAtIndex:row]; NSDictionary *dict = [NSSpeechSynthesizer attributesForVoice:v]; return [dict objectForKey:NSVoiceName];