Dynamic List and Create Company
Intermediate Training Core Data
With our list built out in it's basic setup, we are now ready to enhance it by adding in some dynamic behavior that will show different text per row. We will be doing this by first introducing our Company model object and using an array to store dummy companies. Next we create our form that allows us to create our company objects through our application. Let's present this form modally from the bottom of the screen, and also customize the UI to match our current theme. Using presentation modals is a common technique to switch the user into a different context to perform these types of tasks.

Comments (19)
Denness
5 years ago
Hi Brian, is there a particular reason as to why you chose to present the new view controller rather than using the push view controller method? I always use the push method but wondered if there is a time when it makes more sense for present to be used.
Brian Voong
5 years ago
Denness
5 years ago
That makes perfect sense thank you, I had an idea of why but your explanation has definitely helped consolidate it.
sirybob
5 years ago
Yes. Perfect. Thanks for that clarification
Roger Price
5 years ago
Nice - learned so many tips...including how to calmly deal with xCode quirks and crashes!
sekjn0
5 years ago
Hi Brian and thanks for a stimulating course. In my app the Companies text shows up with small font when the app is launched and when I have pressed Create Company and the Cancel back to the Companies scene then it shows with large font. Any idea why?
lbta
5 years ago
sekjn0
5 years ago
Hi Brian, I downloaded your project but only a generic simulator shows up in the devices window. And that one will not run. How do I get the normal list of devices?
Brian Voong
5 years ago
sekjn0
5 years ago
I updated and that did it, the devices came back. I also found the error when comparing my code to yours. I had put the: UINavigationBar.appearance() etc. code after the: window = UIWindow() window?.makeKeyAndVisible() Moving it to before did the trick. Thanks.
Brian Voong
5 years ago
supriyajagtap2007
5 years ago
Hey Brian, So far I am able to follow all the things you have done. I mostly Prefer Storyboard for all Ui related work including custom Navbar. So I am finding it little difficult to implement the same using storyboards. Will Appreciate if you could also tell us to do the same thing using Storyboard. I am found presenting CreateCompany VC with Navigation controller embedded in bit difficult. It was showing as expected. Can you please tell what could have possible gone wrong. Thanks in Advance.
Brian Voong
5 years ago
Ewerson Castelo
5 years ago
I'm really enjoying working with just the code, without any storyboards. It really allows for greater control over the whole project.
José Luis Cornejo
5 years ago
Hi Brian, I hope you find yourself very well, and congratulations for your courses, they are excellent I have a question: How can I insert a new row in the first row? regards
Paul Dong
5 years ago
Hi Brain, Thanks for providing such a great tutorial! I have a question about the way to present `CreateCompanyController`. In this episode, you have created a new navigation controller to present the next view, which is `CreateCompanyController`, but why don't you push `CreateCompanyController` into the current navigation controller? Here is my code: //CompaniesController private func setupNavigationStyle(){ ... //define cancel button let backBarButton = UIBarButtonItem(title: "Cancel", style: .plain, target: nil, action: nil) backBarButton.tintColor = .white navigationItem.backBarButtonItem = backBarButton ... } @objc func handleAddButton(){ let createCompanyController = CreateCompanyController() navigationController?.pushViewController(createCompanyController, animated: true) } //CreateCompanyController override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .yellow navigationItem.title = "Create a Company" } it works as expected and no need extra coding. I am sure you have done in this way in previous tutorials, is there any benifits to create a new navigation controller?
Brian Voong
5 years ago
Paul Dong
5 years ago
Hi Brain, By reading the discussions, I think either way is OK in this case, if the `Add Company` become more complex (containing child views), it would be better to use present, am I right? BTW, is it possible to support `Markdown syntax` in the Comments area?
Daniel Peach
5 years ago
Hey Brian, this has nothing to do with the course, but these question threads. It seems the answers get stacked on top of each other, which is hard to follow. Don't know if you've noticed this. What it looks like: Question Reply 3 Reply 2 Reply 1 What is should look like (like on youtube and most other places) Question Reply 1 (most likely your answer) Reply 2 (most likely a followup question, or a "thanks" comment) Reply 3 Hope this helps.
Brian Voong
5 years ago
magic
5 years ago
You're the best! Thanks for the great tutorial:)
dclawson
5 years ago
A little off topic, but what if you wanted a day/night mode option? Would you make two extensions: setupDayNavigationStyle() -and- setupNightNavigtionStyle() I guess at that point, you'd just pass an argument into the extension with something like: mode: "night" and then have if/else to set the appearance to a different theme or skin.
Brian Voong
5 years ago
alberto marin
5 years ago
Eii Brian, this video doesn't work. Can you check it pls? Thank you
Anthony hordern
4 years ago
Hey Brian, love the course so far, is there any way to download a lesson to watch when I'm off line ?
Cinquain
4 years ago
Fire as usual!
hcri1950
4 years ago
you are incredible, I simply can not stop right now.
Abdullah Amer II
3 years ago
At first I was hesitate to buy this course, but now Iam so happy that I made this decision. Thanks A lot Brayan
Brian Voong
3 years ago
Christopher J. Roura
3 years ago
Hi Brian, iOS 13, Swift 5, and Xcode 11 have seem to throw things way out of whack. In all of my apps now I am having troubles with the presented view controllers not showing full screen. I am curious to know if you have a better work around even though I know this isn't a bug. For my current attempt at this I have edited the scene delegate file to look like so: import UIKit class CustomNavigationController: UINavigationController { override var preferredStatusBarStyle: UIStatusBarStyle { return .lightContent } } class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). guard let _ = (scene as? UIWindowScene) else { return } let navBarAppearance = UINavigationBarAppearance() navBarAppearance.configureWithOpaqueBackground() navBarAppearance.titleTextAttributes = [.foregroundColor: UIColor.white] navBarAppearance.largeTitleTextAttributes = [.foregroundColor: UIColor.white] navBarAppearance.backgroundColor = .lightRed UINavigationBar.appearance().prefersLargeTitles = true UINavigationBar.appearance().standardAppearance = navBarAppearance UINavigationBar.appearance().scrollEdgeAppearance = navBarAppearance let companiesController = CompaniesController() window?.rootViewController = CustomNavigationController(rootViewController: companiesController) } func sceneDidDisconnect(_ scene: UIScene) { // Called as the scene is being released by the system. // This occurs shortly after the scene enters the background, or when its session is discarded. // Release any resources associated with this scene that can be re-created the next time the scene connects. // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). } func sceneDidBecomeActive(_ scene: UIScene) { // Called when the scene has moved from an inactive state to an active state. // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. } func sceneWillResignActive(_ scene: UIScene) { // Called when the scene will move from an active state to an inactive state. // This may occur due to temporary interruptions (ex. an incoming phone call). } func sceneWillEnterForeground(_ scene: UIScene) { // Called as the scene transitions from the background to the foreground. // Use this method to undo the changes made on entering the background. } func sceneDidEnterBackground(_ scene: UIScene) { // Called as the scene transitions from the foreground to the background. // Use this method to save data, release shared resources, and store enough scene-specific state information // to restore the scene back to its current state. } }
frankusu
3 years ago
Hey Brian, In iOS 13 presenting modally shows CreatingCompany on top of CompaniesController and you can just drag down to clear CreatingCompany. Do you recommend using cancel button still ? Thanks man !
froggomad
3 years ago
This is an awesome course Brian! I appreciate how you break everything down and use common practices. One note I have is that it's becoming more common to use Model Controllers and call them ModelNameController. While I stopped naming my ViewControllers XViewController and went with XController for a few years - this got me in a tight spot with naming conventions when I started using Model Controllers recently. In this example CompaniesController wouldn't be specific enough to identify a ViewController. Thanks for the great course!
Brian Voong
3 years ago
Matthew Easton
3 years ago
Hi Brian, when you said to leave AppDelegate alone and to instead use SceneDelegate does that only apply to the setup steps in video 2 or to all instances where you mention AppDelegate? Thanks
Brian Voong
3 years ago
HELP & SUPPORT