Feb 012012
 

Here comes 3rd wave …

1. compare strings
It seems NSString did not overload the compare operator (==), or maybe Object-C does not have this kind of idea, so don’t use == to compare strings, instead, you need to use compare: or caseInsensitiveCompare: and their dialects.

2. catching cell selection event in a table view
I was trying to subclass UITableViewCell to make it works, but actually don’t have to be this complicated – all that I need to do is deal with “- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath” in the table view, and this saves me a lot of effort as I don’t have to go through all the difficulties to get storyboard, etc with codes within a Cell class.

3. singleton, property or method?
I created a singleton class, then found in Object-C, it’s better to static method (if you can) instead of property. It takes quite a lot keystrokes to use a property, while using method is not that hard.

4. passing data to a view controller in a storyboard based application
– define a property of the child view controller for holding data
– in parent view controller’s prepareForSegue, set the property of the child controller
– that’s it …

Sorry, the comment form is closed at this time.