Objective-CでのTips UIControllerなど

UINavigationControllerに関する忘れがちなメモ

// UITableViewのCellをクリックしたときの動作
detailViewController * detail = [[detailViewController alloc]initWithNibName:@"detailViewController" bundle:nil]; // extends UITableView
[self.navigationController pushViewController:detail animated:YES];
[detail release];

// UITableViewCellに追加するボタンのUI名
UITableViewCellAccessoryDetailDisclosureButton

HttpConnectionWrapperをつかったHttp request

Objective-cでhttp requestするのはそんなに難しくはないのですがHttpConnectionWrapperをつかって手軽にhttp requestができます。
https://gist.github.com/911999

.hファイル

#import "HttpConnectionWrapper.h"
@interface yourClass : NSObject <HttpConnectionWrapperDelegate> // delegateプロトコル
@end

.mファイル

-(void) yourMethod
{
    HttpConnectionWrapper * httpConnection = [[HttpConnectionWrapper alloc] init];
    httpConnection.delegate = self; // デリゲートしてあげてください
    [httpConnection startWithString:@"http://www.yahoo.co.jp/"];
    
}
// HttpConnectionWrapperの結果受け取り
-(void)didReceiveAllResponse:(HttpConnectionWrapper *)connection withString:(NSString *)string
{
    // do something
    NSLog(@"%@", string);
}

変更可能な配列の配列を出力する(NSMutableDictionary, NSArray)

NSMutableDictionary * dic = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"value1",@"key1", @"value2", @"key2", nil];
NSArray * keys = [dic allKeys];
for(int i=0; i<[dic count]; i++){
    NSLog(@"%@", [dic objectForKey:[keys objectAtIndex:i]]);
}

phpだと

$dic = array('key1'=>'value1', 'key2'=>'value2');
foreach($dic as $key=>$val){
    echo $val;
}

NSDictionaryをfor文で展開

NSDictionary * datas; // here NSDictionary hashs
for(NSString *key in datas){
    [datas objectForKey:key];
    // do something
}