Chapter 27 p644 for swift version 4.2. find UITabBarController

@fahim and everyone:

Hi, I have added a new view controller to the my location app, now the UITabBarController is not the root view controller anymore, how can I keep the code valid?

In the book says I first have to find the UITabBarController, how to find it?
let tabController = UITabBarController as! UITabBarController something like that?

I have given the TabBarController an storyboard id “AppContent”, but unable to call it.
Please help.

Thanks

Please help, anyone?

Hi, this topic is solved, I watched the youtube video made by Kilo Loco, Core Data: Saving to the Device | Swift 4, Xcode 9 - YouTube, solved by creating a singleton, I called it persistence service, next moved all of the core data related methods from app delegate to the singleton, and change them to static.

Now because the app is designed with dependancy injection, for every NSManagedObjectContext in all the views, just call the static context, so no need to locate the view again.

1 Like

@jdfocus1985 Glad you were able to solve this and also thank you for sharing how you found your solution.

Hi, thanks for the reply, learners like me need many app for practicing, and iOS apprentice is a great book. Wish that I can learn how to build a translator app.

1 Like

I have watched the video. I am not sure if he is technically using a Singleton there. There is a private init but not a static instance.

I wonder what the authors of this helpful book would think about using the singleton design pattern for sharing NSManagedObjectContext among ViewController classes in Chapter 27 of iOS Apprentice 7th Edition. I can’t see this topic anywhere in the book. I would appreciate if they could share their valuable opinions with us. Thanks!

This topic was automatically closed after 166 days. New replies are no longer allowed.