fix return type of AVSpeechSynthesisVoice:new

This commit is contained in:
François Caddet 2020-09-05 11:30:11 +02:00
parent 1b8809aaeb
commit b238c8c938
1 changed files with 5 additions and 3 deletions

View File

@ -11,10 +11,12 @@ pub struct AVSpeechSynthesisVoice(*const Object);
impl AVSpeechSynthesisVoice { impl AVSpeechSynthesisVoice {
pub fn new(identifier: &str) -> Self { pub fn new(identifier: &str) -> Self {
let voice: *const Object;
unsafe{ unsafe{
let i: id = NSString::alloc(nil).init_str(identifier); let i: id = NSString::alloc(nil).init_str(identifier);
msg_send![class!(AVSpeechSynthesisVoice), voiceWithIdentifier:i] voice = msg_send![class!(AVSpeechSynthesisVoice), voiceWithIdentifier:i];
} };
AVSpeechSynthesisVoice{0:voice}
} }
pub fn default() -> Self { pub fn default() -> Self {
@ -24,7 +26,7 @@ impl AVSpeechSynthesisVoice {
pub fn list() -> Vec<Self> { pub fn list() -> Vec<Self> {
let voices: CFArray = unsafe{msg_send![class!(AVSpeechSynthesisVoice), speechVoices]}; let voices: CFArray = unsafe{msg_send![class!(AVSpeechSynthesisVoice), speechVoices]};
voices.iter().map(|v| { voices.iter().map(|v| {
AVSpeechSynthesisVoice{0: *v as *mut Object} AVSpeechSynthesisVoice{0: *v as *const Object}
}).collect() }).collect()
} }