Group Group Group Group Group Group Group Group Group

Chapter 15.9 EnvironmentObject usage


Here is the moment at the end of the chapter, that describes “you need to add EnvironmentObject to ReaderView”:

  • One as a property - @EnvironmentObject var settings: Settings
  • Second as pass param to SettingView - .environmentObject(self.settings)
    But, even if I’ll not do this - everything works as expected. So, what is the real reason to do this?
    In challenges of 15.10 - yes, you need this, but before I don’t understand why this should be done
    Can you explain, please?

I’ll check the source today and let you know - it’s possible that we pulled the instructions into the chapter so that readers don’t have to figure out everything on their own in the challenge.

You are right - the property isn’t needed per se in the chapter - only in the challenge. I guess my intention initially was to have less guesswork in the challenge for the readers but, to your point, there’s no need to spoonfeed everything like that to the reader.

I removed that paragraph and we’ll push the change with the next update, thanks a lot for pointing this out.