Logging Excessive Blocks on the Main Thread

Logging excessive blocks on the main thread

Having an application running at 60 FPS is every programmers dream, and users delight. The worst users experience ever is a frozen and unresponsive screen. It’s a dreadful crime in mobile world nowadays. Users try to interact at any moment and according to Murphy’s law they will find all your mistakes. So, you better keep the main thread slim.

Autolayout and NSLocalizedString

A localized application is the one that has all of its texts, translated into the users device current language. And this, for us developers, means one thing, and one thing only. Nightmare.

Every time a new translation comes, it’s necessary to run the application and check for broken layouts. Take this quite simple UI.

Don't Forget About UIMottionEffect

UIMotionEffects was first introduced in iOS 7. The WWDC session which presented this, amongst other cool things, is named Implementing Engaging UI on iOS. Nevertheless, UIMotionEffects is still overlooked. But not today, let’s make something cool with it.

Motion effects is an easy way to react to external variations on the device’s orientation. To say, UIKit performs UI changes whenever the user tilts the device, vertically or horizontally.

Let’s use UIInterpolatingMotionEffect a subclass of UIMotionEffects, with MapKit. Notice how appealing it is.

Autolayout Breakpoints

Auto layout has become a crucial tool for iOS and OS X development. It makes creating layout for multiple screen sizes easy peasy. But sometimes it can drive you crazy, with verbose and misleading logs.

NSProgressReporting

In iOS7 and OS X 10.9 Apple released NSProgess. Its a nice, helpful piece of code that was supposed to make our coding lifes easier. If you finally find a proper way to use it it can be very beneficial.

Besides of helpfull UserInfo object keys which give us comprehensive text information about progress of our tasks in proper language, NSProgress was supposed to provide us way of compositioning objects into trees. However, first version of class allowed this in an implicit way which does not look very clear first time you learn it.

Using Sql as Date Formatter

This post is a quick update to Vombat’s blog post about using SQL instead of NSDateFormatter when it comes to parsing dates in your project. If you don’t read it yet, I will highly recommend to do it now. This time we will use Swift to make same measurements.

Law of Demeter

You may haven’t heard about this law or if you have, you may have wondered who’s this Demeter guy. Regardless of it, the Law Of Demeter (LoD) is a foundation concept that’s used among several design patterns, to wit: Delegate, Proxy, Façade, Adapter and Decorator. Therefore, you probably are already taking advantage of this Law, knowing it or not.

Run Script Phase Reporting

Bash scripts are commonly used in Mac/iOS development to make repetitive operations hands-free. However sometimes things go wrong and in a perfect world I’d like to be properly informed about the errors. Here comes view called „Report Navigator”, which displays any type of errors, warnings at compile time of Objective-C/Swift, or even while typing new lines of code. Let me show how to use the Report Navigator.

UICollectionViews Now Have Easy Reordering

I’m a huge fan of UICollectionView. It’s way more customizable than his older brother UITableView. Nowadays I use collection view even more often than table view. With iOS 9 it supports easy reordering. Before it wasn’t possible out of the box, and to do so means painful work. Let’s have look at the API. You can find the accompanying Xcode project on GitHub.

Shared Breakpoints

Developing multithreaded application is not something new and it’s become more and more popular with multicore processors. One thing it’s for sure, debugging multithread applications is tough.

iOS has some gotchas regarding multithread, things that if you don’t respect, may cause your application to crash or hang the users interface, for example: