2012年2月7日 星期二

[iOS Dev] Parse query string into dictionary

Usage:
NSString *qs = @"username=hank&age=27&blog=whhnote.blogspot.com";
NSDictionary *queryParams = [self parseQueryString:qs];
NSLog(@"%@", queryParams);
NSLog(@"%@", [queryParams objectForKey:@"username"]); // get username from dict
So, you will get a dictionary look like
{
    age = 27;
    blog = "whhnote.blogspot.com";
    username = hank;
}

2012年2月1日 星期三

[Xcode] 設定預設文件開頭的 Organization

原本預設是 ___MyCompanyName___, 這樣新增檔案都要改一次

在Ternimal直接下此指令更改預設值
defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions '{ORGANIZATIONNAME="Hank's Company";}'

之後就不用改了

[iOS Dev] NSUserDefaults Save/Read/Clear 儲存/讀取/清除 速記

參考: NSUserDefaults Class Reference

2011年12月8日 星期四

[MongoDB] update one field of all records 更新所有資料裡的某個欄位

Usage: db.collection.update( criteria, objNew, upsert, multi )

MongoDB shell:
> db.users.update({}, {$set : { subscribe : true }}, false, true)

[MongoDB] print one field of all record 列出所有資料裡的某個欄位

MongoDB Shell:

> db.users.find({}, {email:1}).forEach(function(u) {print(u.email)})
Related Posts Plugin for WordPress, Blogger...