Demystifying Views in iOS · Controlling Parent Views | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4518-demystifying-views-in-ios/lessons/12

The example is far too complex. You may as well call it “Mystifying Views”. I’m an experienced iOS dev and could barely keep up. I can only imagine how intimidating this would be for new learners.

You need simpler more focused examples - start with 1 parent and 1 child and the relationship between them first.

@gsharm1 Thank you for your feedback - much appreciated! Could you please let us know what didn’t you understand exactly?

@gsharm1 Thanks very much for your suggestion. I wanted to make a few points here:

  1. In fairness, the course is marked “Intermediate”, and thus, is not intended for novices.

  2. Because the video tutorials are accessible via a paid subscription, users who have access to the content have higher expectations on the quality we provide, and tend to expect more than just a rudimentary explanation.

  3. Because they are in video, one also has the luxury of having access to both the visual demonstration of what is being done, as well as the corresponding audio. So while the video is playing, one also has the means to listen to the audio to gain a better understanding of what is going on. So while the content may be a bit more complex, you do have additional means to help you understand.

  4. You do have the ability to replay the videos multiple times to review any concepts that you may have found difficult.

  5. The purposes of the forums here are intended for precisely just that: A means to get your questions answered for topics that were discussed in the video course (or book, or article), which is still causing you confusion :slight_smile:

I hope this helps!

All the best!

Hi! Is there any particular reason why you chose to let the LessonViewController handle the animateOut(:delay:handleCompletion:) functionality and not include it with the UIView extension? Also, could the way you designed the completion handler in this scenario also have been applied to the animateIn(:), like so:
completion: [ handleCompletion = handleCompletion ?? { return } _ in handleCompletion() ]

And would it have been an option to lazily load the LessonImagesView from the .xib file once, or alternatively in viewDidLoad(), instead of loading it up again every time pickNewCard() is called?

Lastly, I’d be interested to hear how you would go about designing a project like this in “real life”. Looking at all the code, .xib files and UIView swift files, I’d have absolutely no clue as to where to get started implementing all that logic. I mean it makes perfect sense looking at it after having gone through the tutorial, but if I had to start over from scratch, I’m not sure I would get even close to what you did here. Where do you start? Do you refactor a lot or have a clear view on what logic goes where right from the start? Would be glad for some insights or tips on how to go about something like that as a beginner.

Is there any particular reason why you chose to let the LessonViewController handle the animateOut(:delay:handleCompletion:) functionality and not include it with the UIView extension?

animateIn will be used by multiple view controllers, but animateOut is only used by LessonViewController, so I didn’t feel a need to elevate it to “project-scope”.

Also, could the way you designed the completion handler in this scenario also have been applied to the animateIn(:)

Your code executes something when handleCompletion is nil. That’s not the same thing as passing nil as animate's completion argument, but it’s so close that if you want to write it that way, no big deal.

And would it have been an option to lazily load the LessonImagesView from the .xib file once, or alternatively in viewDidLoad() , instead of loading it up again every time pickNewCard() is called?

Storing a UINib for instantiating is the next place to go if performance becomes an issue.

Lastly, I’d be interested to hear how you would go about designing a project like this in “real life”.

I’ve found that matching up code files to what’s in storyboard/nib files to be a great place to start, with UIKit. I’ll put code in exactly the most drilled-down place I need it, and then refactor, moving it to be more accessible, only if the need arises.

We’ll all have differing opinions about how exactly code/organization should look. As long as the end result functions as you expect, then what you’ve created is doing its job!