Hopefully most of you are familiar with the concept of the Container View Controller. It’s a really useful Cocoa feature that I find myself using more and more lately. I won’t go into its implementation details, though, since you can find it in Apple’s doc.

Let’s dive into some scenarios where I find it super useful.

  1. Embed UITableViewController. Everybody has been there. You have a table, and some other content around. Most people just add UITableView into their UIViewController subclass. But this way you throw away a lot of the functionality that you get for free via UITableViewController, such as:

    • autoscroll to focused UITextField and UITextView so that they are not hidden behind keyboard
    • default UITableViewDatasource and UITableViewDelegate implementations
    • flawless pull to refresh

    to name a few. If you put UITableViewController into container you get best of both worlds – flexibility of your own UIViewController subclass for decorating content and built-in functionality of the UITableViewController

  2. Shared screen portions – those which reappear in differents parts of the app. This is especially helpful if you use architectures such as CleanSwift. You can easily reuse complete scenes, with all of their helpers (interactors, routers, workers) already set up.

  3. Display error and empty states of the scene.

  4. Use it for animating controllers because it’s easier to animate UIView with UIViewPropertyAnimator and UIGestureRecognizer than UIViewController using View Controller Transitions. Make a container view with the embedded controller and animate it around as you would with any other view. You can see this approach in DisplayInDrawer lib.

And there are many more scenarios where UIViewController containment can simplify your programmer’s life. But – there is a caveat. Let’s say you have an embedded UITableViewController. You just got the data, so you create a controller, inject the data, embed it, and display. So far so good. New data arrives. Many times on many projects I have seen that the same routine is used. “so you create a controller, inject data, …”. Wrong. You needlessly instantiate a new controller although you already have one. Except this can be expensive (viewDidLoad tends to be quite busy, right?), you can bring in crazy bugs, e.g. register duplicate observers, completion handlers etc. This can get even worse if your controller is not deallocating properly. Although I am sure your controllers do deallocate 👮, because you check that diligently, don’t you?

The solution is to check every time, if the controller exists already, and if it does – just inject the data. Do not make a new instance.

But this can get tedious and you can easily forget to make this check.

Enter UIViewController-DisplayChild extension which mitigates this problem by embedding (displaying) the type instead of instance. You give it controller’s type, configuration closure and a container view. The extension decides whether the controller needs to be instantiated, makes an instance if needed, runs your configuration closure on it and embeds it to the specified container view.

Sometimes you have to transfer a file from one GIT repository to the other. You also need to preserve the history, either to give credits to authors, or simply to know why certain parts of code do exist.

First you have to export all desired files in a patch. Make sure you are running this command from git repository directory:

git log –pretty=email –patch-with-stat –reverse –full-index –binary — <file or directory> > <patch filename>

the patch now contains all commits containing changes to specified files. The next step is to navigate to target repo directory and apply patch:

git am –committer-date-is-author-date < <patch filename>

committer… flag forces commits from patch to maintain their original dates. Otherwise all applied commits would have current date. Sometimes you get a message:

Patch is empty.  Was it split wrong?

If you would prefer to skip this patch, instead run “git am –skip”.

To restore the original branch and stop patching run “git am –abort”.

The reason might be that there are merge commits without actual changes in the history. If you encounter this error just skip empty commits using

git am –skip –committer-date-is-author-date

make sure to include –committer flag, otherwise all consequent commits would have todays date.

Грамотная внутренняя и внешняя оптимизация необходима при продвижении сайта и раскрутке его в интернете topodin, С его помощью можно легко проверить, не получил ли кто-нибудь посторонний доступ к вашему ящику

evolutioncloud.com приватбанк курск кредитная карта

Life is full of changes. Long time friends from riverstone creative house decided to abandon iOS app development business, at least for now. So what about apps we made together? The designer Jozef Mak and I decided to found a company – TapMints. So our apps have been transferred and I can”t wait to hand you all the stuff we are working on.

При этом, запоминать и зубрить название статей online casino нет смысла – online casino фактически, законодательство стран СНГ не имеет гарантированного и работающего законодательства, которое могло бы превратить заявление о защите деловой репутации в конструктивное разбирательство, заканчивающееся удовлетворением иска, Сайты для людей: учимся писать статьи на основании отзывов о товарах., Особенности и преимущества регионального продвижения сайта Создано 16

банк втб открыть расчетный счет