UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: Odd log message caused by automatic grammar agreement

Forums > SwiftUI

Following a YouTube post by Paul a few weeks back, I added inline grammar agreement to several information Text() messages in my app, like this:

Text("I have ^[\(pCocktails.count) recipe](inflect: true) from ")

The following log message appears for each instance:

Cannot use Morphun (checking that the token is the correct type): (null)

The code works as expected except for the log noise. There are no hints to be found via web search, anywhere. Does anyone have an idea how to resolve these, or even just an explanation as to what they mean?

2      

Should't be there string interpolation for \(cocktails.count)?

2      

Seems like you can fix it by indicating what part of speech this should be applied

Text("I have ^[(pCocktails.count) recipe](inflect: true, partOfSpeech: noun) from ")

2      

Yes! That did the trick, thank you.

(I mistyped the string interpolation, leaving out the \ in this forum message...it was correct in my code but left out the partOfSpeech argument.)

Oof...spoke too soon. Adding partOfSpeach: noun did, in fact, resolve the messages I wrote about but now grammar agreement doesn't work.

2      

Indeed, there was no inflection on noun :)

This one seems to work for sure

Text("I have ^[\(pCocktails.count) \("recipe")](inflect: true) from ")

5      

Interesting. Using interpolation notation on the noun did, indeed, both resolve the warning messages as well as activate inflection. I wouldn't have ever figured that out.

Thank you!

2      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.