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 …

Feb 012012
 

This may not be useful to others, but it bothered me quite some time, so I’d like to write it down in case some others stuck at the same place as I did.

getMetadataForKey calls from aws-ios-sdk, actually it:

  1. returns user defined meta data, nothing to do with s3’s meta data
  2. the key used here will be prepended a “x-aws-meta-“, that is, in aws console, we will see a meta data entry keyed with “x-aws-meta-hahaha”, but in ios app you need to use “hahaha” to get the value

some other interesting stuffs … don’t use S3GetObjectRequest/Response call to get object’s header information, as it will indeed download the object. Instead, you should use S3GetObjectMetadataRequest/Response.

To get “Expiry Date” and  “Lifecycle Rule” information as they are shown on aws console, you need to use response”s valueForHTTPHeaderField method with key “x-amz-expiration”, the parse it … I guess there should be something more easier but havenn’t figured out how. Both “expiry-date” and “rule-id” are there so you can use them, note that they can be empty so better prepare for that.

Jan 302012
 

Here comes the second part of ios development tips which follows first part, I’m starting over the number now so to ease my life.

1. How to navigate to a view in another view
– original post is here:
* dealing with views in a storyboard based application
* some other helpful discussions are here: manually switch view controllers in storyboard, and another similar topic
– idea
* actually the basic idea is pretty simple and straightforward – you create a new view (the one you want to display), and push it to the top of the navigationcontroller (which actually is a stack), that’s it …
* tricky part #1: this cannot be done in a viewDidLoad event as view was not fully loaded at that time so you can nothing, the place I found that is workable is viewDidAppear event
* tricky part #2: ViewController’s initWithNibName does not work … I haven’t figure out the exact reason yet but you have to use instantiateViewControllerWithIdentifier comes from storyboard
* tricky part #3: nibname … gave me QUITE A LOT headache, it should be “UIViewController-“, you can get the object ID from Interface Builder, in the identity inspector tab