iOS Development Tips

           A few things I think I've learned that may help you


Learning iOS and XCode

Other Rants and Raves


August 2011 - I've been riding the XCode iOS iMac horse for about six months now. I feel competent, but not expert. Along the way I figured out a few things that someone brand new to this environment might puzzle over. I'll document those here. If you are just starting your iOS journey, you might enjoy reading about my trip

By the way, if you're reading this and discover that one of my "tips" is wrong, please send me an email, I'd like to learn from your experience!


Places I go to for answers:


In iOS, the view that was added last is "on top" for the touch. If touch areas overlap, the one added last gets the touch. You can alter this order with some method calls to the view you want to change.

If the "top" view has userInteractionEnabled = NO, the siblings directly under it get the touch event.

If you add a view as a subview, it uses the coordinates of the parent, i.e. no matter what the parent view origin is, a subview with origin 0,0 will always be positioned in the upper left corner of the parent view.

A sub view can be positioned outside of the parent view frame. If so it will display, but will not get touch events. If a view is a subview and within the parent frame, then the subview gets the touch.

Setting Hidden = YES will make the view and its subviews all disappear and they stop responding to touches.

Setting a view userInteractionEnabled = NO will disable interaction for all subviews too, but the views still remains visible.

A view cannot be a subview to two different views. I had an overlay view that I added to one and then another as sub views. When it was added to the second view it was automatically removed from the first. I guess that makes sense as a view can only have one superview.


Sending a message (making a method call) on an object that is nil does not raise an error. So, if you fail to correctly initialize some instance variable your code can be making calls to the object and you wont know that anything is wrong.

If you get 1000+ errors into the apple libraries, check that you might have put the foundation header in a file that xcode doesn't like. I had the foundation header in a header file that got included in a .cpp file. The .cpp was left over from the port of my Dragonfire project. I changed the .ccp to .m and all the problems went away.


Jim Schrempp is a sometimes freelance writer (only Vanity Press will publish his work) living in Saratoga, California. His writings have appeared on numerous pages on his own web site. The opinions expressed in this piece are those of the writer and do not necessarily represent those of anyone else (although Jim wishes more people shared his opinions)