Monthly Archives: November 2011

git

I started using version control using SCCS – a single user version control system. Then I moved to CVS, which almost made me through a CRT monitor out of a 3rd floor window. Then came SVN and that was better. Now I am using git. Since git’s version control model is distributed, it is taking bit of getting used to.

I found this succinct tutorial, which nicely explains commits, branches, staging etc.

Today I need to add a branch to a project, but I have already made some uncommitted changes. I need the stash.

That is all.

Not abusing UIViewControllers

I having been mulling for a while an interesting conundrum. I have some code, which is designed to work as a library. It makes no assumptions about any view controller which is active when it is used, and so directly adds things to the view using addSubview: on the application’s main window (view). The initial problem with this approach is that the newly added views have no view controller.

I fixed that by defining a view controller with an appropriate view, but then how to get that displayed. Without any assumptions about the context in which the code is used, the best I could do was instantiate the view controller and then add its view as a subview of the application’s main window as before. An immediate undesirable I discovered was that the new view controller’s viewDidLoad: was never called.

After some fishing around, I found a few useful articles:

Abusing UIViewControllers – presents the case that you should NOT do what I initially do above, force the new view controller’s view into the view hierarchy.

Writing high-quality view controller containers – discusses the same problem and how to write custom view controllers which manage multiple view controllers, like the iOS SplitViewController.

The solution I am going to adopt now is to require the code calling the library to provide a view controller onto which the new view can be pushed using pushModalViewController: