{"id":1242,"date":"2012-02-01T13:55:57","date_gmt":"2012-02-01T20:55:57","guid":{"rendered":"http:\/\/xiehang.com\/blog\/?p=1242"},"modified":"2012-02-01T13:55:57","modified_gmt":"2012-02-01T20:55:57","slug":"ios-development-tips-3","status":"publish","type":"post","link":"https:\/\/xiehang.com\/blog\/2012\/02\/01\/ios-development-tips-3\/","title":{"rendered":"ios development tips #3"},"content":{"rendered":"

Here comes 3rd wave …<\/p>\n

1. compare strings
\n 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.<\/p>\n

2. catching cell selection event in a table view
\n I was trying to subclass UITableViewCell<\/a> 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.<\/p>\n

3. singleton, property or method?
\n 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.<\/p>\n

4. passing data to a view controller in a storyboard based application
\n – define a property of the child view controller for holding data
\n – in parent view controller’s prepareForSegue, set the property of the child controller
\n – that’s it …<\/p>\n","protected":false},"excerpt":{"rendered":"

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 […]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[47,252,280],"_links":{"self":[{"href":"https:\/\/xiehang.com\/blog\/wp-json\/wp\/v2\/posts\/1242"}],"collection":[{"href":"https:\/\/xiehang.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xiehang.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xiehang.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xiehang.com\/blog\/wp-json\/wp\/v2\/comments?post=1242"}],"version-history":[{"count":1,"href":"https:\/\/xiehang.com\/blog\/wp-json\/wp\/v2\/posts\/1242\/revisions"}],"predecessor-version":[{"id":1243,"href":"https:\/\/xiehang.com\/blog\/wp-json\/wp\/v2\/posts\/1242\/revisions\/1243"}],"wp:attachment":[{"href":"https:\/\/xiehang.com\/blog\/wp-json\/wp\/v2\/media?parent=1242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xiehang.com\/blog\/wp-json\/wp\/v2\/categories?post=1242"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xiehang.com\/blog\/wp-json\/wp\/v2\/tags?post=1242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}