У меня возникла проблема с отправкой продиктованного текста на другой контроллер интерфейса.
Вот мой код:
- (IBAction)voiceRecognition {
[self presentTextInputControllerWithSuggestions:nil allowedInputMode:WKTextInputModePlain completion:^(NSArray *results) {
NSLog(@"results: %@", results);
NSString *wordKey = [NSString stringWithFormat:@"%@",results];
NSDictionary *dict = @{@"kWord":wordKey};
[self pushControllerWithName:@"Dictionary" context:dict];
}];
}
Журналы:
Смотреть расширение [3185: 2835671] результаты: (Привет)
Получение данных от другого контроллера интерфейса:
- (void)awakeWithContext:(id)context {
[super awakeWithContext:context];
NSDictionary *dict = (NSDictionary *)context;
[_word setText:dict[@"kWord"]];
NSLog(@"The Word is %@",[dict description]);
}
Журналы:
Watch Extension[3185:2835671] The Word is { kWord = "(\n Hello\n)"; }
Вот снимок экрана, который показывает мою проблему:
Предполагается, что (
показывает слово Hello
. Как я могу решить эту проблему?