iOS Design Patterns - Part 2: Project Setup | Ray Wenderlich

Learn two ways to structure your project for design patterns, "grouping by function" and "grouping by type" and learn which is best for your project.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3816-ios-design-patterns/lessons/2

Just a small quibble about the solution provided for the Über challenge…

The revised code in the showHomeInfoController method actually uses a different view controller as the input parameter for the showDetailViewController than the original code does.

Here’s the original code:

fileprivate func showHomeInfoController() {
        let bundle = Bundle(for: type(of: self))
        let storyboard = UIStoryboard(name: "HomeInfoBuilder", bundle: bundle)
        let navigationController = storyboard.instantiateInitialViewController() as! UINavigationController
        let viewController = navigationController.topViewController as! HomeInfoViewController
        viewController.delegate = self
        viewController.homeInfo = MutableHomeInfo()
        splitViewController!.showDetailViewController(viewController, sender: nil)
}

Note that the view controller passed into the showDetailViewController method is not the underlying navigation controller but rather the HomeInfoViewController.

Now here’s (part of) the suggested solution to the challenge:

fileprivate func showHomeInfoController() {    
    let viewController = HomeInfoBuilder.instantiateNavigationController(delegate: self)
    splitViewController!.showDetailViewController(viewController, sender: nil)
}

Note that the provided implementation of the HomeInfoBuilder.instantiateNavigationController function, as its name implies, returns the underlying navigation controller, so the showDetailViewController is being passed a different view controller than above.

In practice, the app looks the same, so it’s not something that the end user would notice, but given that this series is all about clean and consistent code, it may be worth fixing this little issue.

come on, this is supposed to be toturial for developers, not kids show. it was really disgusting for me. instructors acts like he is in a baby show !!!

Hey @faani

Said instructor here.

The RayWenderlich community is great because everyone is genuinely trying to advance the state of development and is open to helping one another.

With that said, I really put a lot of time and effort into making this video series educational yet also entertaining.

If you have genuine comments or suggestions for improvement, please do feel free to let me know. We’re actually in the process of making a massive update and adding new videos to this video series. We hope to have this available soon.

If you have questions about the materials here, please also feel free to post comments about such.

Otherwise, please be careful about posting disparaging comments like this— individuals like myself spent a lot of effort to make this material as easy as possible for you to learn, often meaning late nights as making these videos are in addition to full time careers and families.

All the best,
Joshua