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.
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
UITextView so that they are not hidden behind keyboard
- 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
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.
Display error and empty states of the scene.
Use it for animating controllers because it’s easier to animate
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.
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.
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.
Finally, our new app is live on the App Store. It”s name is Weigh Me. It can guide you to keep your weight healthy, with the bonus of awarding you for your achievements – this might help you to stay motivated. Feel free to check it.
From the development or design point of view, there are many animations. It did take some time to develop all this, but the time was well spent. The amount of learning myself was enormous and it was a lot of fun, so I do not regret a single second spent on this project and our team is proud of this app. We hope users will get as much fun while using it as we had during development.
ShareKit is a popular iOS framework, which can easily enable your app to share content on various social networks, such as Twitter, Facebook, LinkedIn, … etc. Some time ago I implemented in our app, and realised, that it is far from perfect. Now things have changed, ShareKit is more matured and a lot of people are submitting pull requests – ShareKit is much more usable and stable than it was few months ago. I am proud to announce, that it has been refactored to be used as Xcode subproject, using a static library. In case you have never heard about Xcode subproject, you can learn about it here, or here.
After you download ShareKit files using git, and add it to your Xcode project as subproject you gain the ability to seamlessly upgrade. Basically you only pull changes from shareKit”s origin repo and run your app. Everything is running, even if we added new sharers, or added/removed files. Prior to this change you had to manually add new files to your project and many of you were probably not aware of new sharers added to ShareKit. I hope this change will make using and updating ShareKit much, much easier.
Sometimes you face a little more advanced search&replace need in Xcode. I had to solve this puzzle – original string, can be placed anywhere in multiple source files:
where <whatever> can be any text. Needed to change to:
To find the strings using regular expressions enter
to the search field. OK, but how to tell Xcode to use the result in the replace field? Regular expressions offer some help: back references and capture groups. First you need to create capture group (think of it as a variable), so let”s slightly change the search regex:
The red parentheses create the group #1 for back reference. Now to the replace field enter
where \1 is back reference to the capture group #1.
side note: the search regular expression supposes, that in <whatever> text there is no “)”.
AppSoundEngine is a very fast low latency framework built upon System Sound Services for easy implementation of user interface sound effects within your iOS application. It is basically a objective-c wrapper around SystemSoundID (representing system sound object) and System Sound Services raw C functions, most importantly sound completion.
What is its history and what kinds of problems does it solve?
During development of Countdown Me I had to solve some problems with sound effects.
First of all – latency. Latency is the delay between pressing the button and actually hearing the sound. Acceptable latency is <10 ms. If you happen to squeeze it like this, the user has a “hardware” feeling of immediacy. SoContinue reading
Now we have also Lite version of Countdown Me for you to try. It may be handy for you, even if you happen to have full version – you can have two events on the badge now.
We are proud to say, that new major version of our app is ready for you to download.
- calendar integration: you can pick existing event from calendar, or create countdowns as new calendar events
- alerts are now local notifications
- new icon
- many small enhancements and bugfixes