我为这行代码得到了以下问题.
"格式字符串不是字符串文字(可能不安全)"
NSLog([NSString stringWithFormat:@"%@", entered]);
Run Code Online (Sandbox Code Playgroud)
有什么建议?
我正在尝试将这个应用程序“说”的单词打印到控制台上,以便我可以将它存储在一个变量中以备后用。函数就像这样,我试图打印变量“word”中的内容。我该怎么办?
- (void)speak:(NSString *)words {
if ([synth isSpeaking]) {
NSLog(words);
return;
}
AVSpeechUtterance *utterance =
[AVSpeechUtterance speechUtteranceWithString:words];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"];
utterance.rate = 0.75 * AVSpeechUtteranceDefaultSpeechRate;
[synth speakUtterance:utterance];
}
Run Code Online (Sandbox Code Playgroud)
我试图在那里添加 NSLog(words),因为我认为这是解决这个问题的方法。但是,我收到一个错误,这不起作用。我将它添加到上面的代码块中只是为了清楚地说明我所做的。