Before I left Germany in November 2014 for 5 weeks going to Indonesia and Thailand, I released HeapInspector, which is an iOS debug tool that monitors the memory heap in your app. You can discover memory leaks, no longer needed living objects and more issues directly on your device without ever starting Instruments. Any suggestions or proposals are very welcome. Or just start a Pull Request.

The idea for the HeapInspector was in my mind for a long time. Since ARC is alive we have less crashes or memory pressure. But you can still do a lot of things wrong (retain cycles, static pointer). I’ve seen memory design mistakes that caused crashes and strange behavior in apps. Those errors are mainly caused by a growing codebase and accompanying architecture problems. Identifying those issues  is not easy and time consuming. Apple Instruments can help to analyze the iOS app for memory issues. That is fine if you have enough time and a cable for tethered debugging with your Mac. But for real life debugging (on trains or subways) Instruments wouldn’t be the ideal solution. For some projects we added a label that displayed the current memory usage in Megabytes. This helped us to identify increasing memory and pressures while using the app in real world conditions (bad 3G and so on).
But to find the main reason (i.e. retain cycles) why the memory increased I needed to run Instruments again.
I asked myself: Is there a way to measure and snapshot the memory footprint on the device without Instruments. YES. I need to override ARC and swizzle retain, release, alloc, dealloc,…
I started digging into Clang’s ARC documentation. Also mike ash’s articles inspired me and helped me a lot to understand what goes on behind the scenes. (See links below)

Some Inspirations, Credits & Thanks

UICollectionViewCell Height Bug

UICollectionView is not the newest Apple stuff. But this bug is really annoying. First I expected it’s something wrong with my code. But after isolating the issue, it became clear, that it is a nasty UIKit bug.


This demo project on github demonstrates the UICollectionViewCell’s height bug when the dataSource (controller) returns a zero height for the 1st sections 1st row cell. The bug occurs with the following setup:

  • the UICollectionsView has 2 sections
  • The 1st section has one row
  • This row has a zero height for the cell
  • Result => the following UICollectionView cells (in bounds) are NOT visible, but the collectionView can be scrolled, looks like that the cells are hidden
  • I filed a bug report: rdar://18120029

Yes, I filed a bug report. As often: No response.

Let’s build an iOS app in Swift and own frameworks: WikiLocation

[Update July 23.] Apple added access control in Beta 4 which means that I have to adapt the new behavior (explicit exposing methods for public access) for my example frameworks. Right now I’m traveling around. This will be done later in August. [/update]
Enough theory, enough reading in Swift. Now it is time to build a real app. With this blog post I will demonstrate Swift. This is not a tutorial how to build iOS apps from scratch. I assume that you are familiar with building iOS apps in Objective C. The purpose of this article is to explain some Swift features, pitfalls and patterns with code snippets.
What is this app about? The app’s name is WikiLocation. As the name implies, it uses your current location and provides you nearby Wikipedia articles. (Buildings, lakes and so on). Straight forward. Not too much magic.
This mini app covers ViewControllers, Views & Models in Swift and custom iOS Frameworks (modules) :

Continue reading

Xcode 6 and Interface Builder – Cool Stuff

Now I see a lot of benefits in working with IB instead of custom UIView classes. (This should be the end of the good old debate IB vs Code.

  • @IBInspectable which gives you access to your custom class properties & @IBDesignable which updates your interface in IB in realtime without compiling the app and launching simulator. There is an tutorial here which goes into more detail. Add the @IBInspectable in front of your properties and change the value via the didSet observer.
    @IBInspectable var borderWidth:CGFloat = 0.0 {
        didSet {
            layer.borderWidth = borderWidth

    Interface Builder properties
    from now on you can change the custom property in the Interface Builder.

    Add @IBDesignable in front of the class

    @IBDesignable class YourCustomCell : UITableViewCell {

    See your custom UI in real time without running the app. Note: You need to put the class with @IBDesignable in a framework.

  • iOS Frameworks – Now we don’t need to stick with static libs. Using capsulated frameworks including assets is a big win in iOS 8. It looks like that Apple is encouraging the developers to use frameworks as often as possible (also for UIView components)
  • View debugging:  Reveal like feature to display the view hierarchy  – Now in Xcode you can snapshot the current view hierarchy and inspect the stack in 3D like in Reveal. Continue reading

App Usability: How-To incapacitate users

App Anleitungen
Imagine: In front of every stair case has an how-to: “Raise your legs, in order to go upwards”. This is what app developers / designers do with theirs users: How-Tos after launching the app. Actually the iPhone and all apps are famous for the good UX from the first day in 2007. There is no instruction guide packaged with your iPhone, because it is so easy.