After the long introductory post, I decided that it would be more beneficial to look at individual aspects of Objective-C instead of having long posts.
Using strings as variable names One of the features that I love about PHP and is lacking in many languages is the ability to use a string to represent a variable name. In PHP, the code looks something like this:
<?php $a = ''hello world!
Ever since we standardized our development platform on the Zend Framework, I’ve been investigating how to utilize its DB classes in our model classes. I have read many articles and opinions on using ActiveRecord and integrating with frameworks like Doctrine. However, I decided that I needed a compelling reason to add another framework to our codebase that I would need to maintain and train our developers on. Not to mention, I like the Table_Data_Gateway and Row_Data_Gateway patterns well enough.
While working on some code that changes a subview’s height/width based on the iPhone orientation, I discovered that if the user rotates the phone while on the navigation controller, the image view controller that gets pushed onto the navigation stack does not change its orientation to match.
I assumed incorrectly that whenever a parent’s willAnimateRotationToInterfaceOrientation:duration: is called, the subview’s would also be called. My first working thought was to store a UIInterfaceOrientation reference in my image view controller and whenever the willAnimate… method is called, it would set the reference.
It is easiest to learn a new language by comparing it to a language you already know. When I learned Laotian, I was taught its alphabet in a similar way you are taught English: A is for Apple. In Lao, ກ is for ໄກ່. Just by learning the alphabet, I could pair words to their English equivalent. I learned that ໄກ່ = chicken, ຂ້ອຍ = I, me, mine, my (depending on context).