玩象棋跟玩西洋棋時, 你只要看到棋子, 就能很快辨別出那只棋子的正確位置
你總不會把"將軍"擺在"車"的位置, 或是把"騎士"擺在"皇后"的位置, 甚至把象棋的棋子放到西洋棋盤裡
"把對的人擺在對的位置" 很重要
或許你還不能當玩這盤棋的人, 只能當一只棋子
在遇到把你擺在那個對的位置的人之前, 你要懂得尋找自己的方向
更重要的是, 如果明知道別人把你擺在錯的地方, 你也要試著自己走回那對的位置
#!/usr/bin/env bash | |
out/host/linux-x86/bin/mkyaffs2image -f out/target/product/generic/system out/target/product/generic/obj/PACKAGING/systemimage_intermediates/system.img | |
out/host/linux-x86/bin/acp -fpt out/target/product/generic/obj/PACKAGING/systemimage_intermediates/system.img out/target/product/generic/system.img |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
NSString *path = [[NSBundle mainBundle] pathForResource:@"data" ofType:@"json"]; | |
NSString *jsonString = [[NSString alloc] initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:NULL]; | |
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding]; | |
NSDictionary *json = [self parseJSON:jsonData]; | |
} | |
- (NSMutableDictionary *)parseJSON:(NSData *)data | |
{ | |
NSError* jsonParsingError; | |
return [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&jsonParsingError]; | |
} |
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://www.apple.com"]]; |
fe80::1%lo0 domain.local就會發現速度變超快! 原來不是Apache的問題
webView.scrollView.scrollsToTop = NO;
[inputTextView becomeFirstResponder]; [inputTextView setKeyboardAppearance:UIKeyboardAppearanceAlert];
NSArray *args = [[NSArray alloc] initWithObjects:@"Apple", @"iOS", @"5.1", nil]; | |
NSLog(@"%@", [args componentsJoinedByString:@" "]); |
Apple iOS 5.1
for (id subview in webView.subviews) | |
if ([[subview class] isSubclassOfClass: [UIScrollView class]]) | |
((UIScrollView *)subview).bounces = NO; |
- (NSDictionary *)parseQueryString:(NSString *)query { | |
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:6]; | |
NSArray *pairs = [query componentsSeparatedByString:@"&"]; | |
for (NSString *pair in pairs) { | |
NSArray *elements = [pair componentsSeparatedByString:@"="]; | |
NSString *key = [[elements objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; | |
NSString *val = [[elements objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; | |
[dict setObject:val forKey:key]; | |
} | |
return dict; | |
} |
NSString *qs = @"username=hank&age=27&blog=whhnote.blogspot.com"; NSDictionary *queryParams = [self parseQueryString:qs]; NSLog(@"%@", queryParams); NSLog(@"%@", [queryParams objectForKey:@"username"]); // get username from dictSo, you will get a dictionary look like
{ age = 27; blog = "whhnote.blogspot.com"; username = hank; }
defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions '{ORGANIZATIONNAME="Hank's Company";}'
// 定義名稱 define key | |
#define kIsActive @"isActive" | |
#define kUserName @"userName" | |
// 讀取資料 | |
-(void)loadInfo { | |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
NSLog(@"Name : %@", [defaults stringForKey:kUserName]); | |
NSLog(@"isActive : %@", ([defaults boolForKey:kIsActive] ? @"YES" : @"NO")); | |
} | |
// 儲存資料 | |
-(void)saveInfo { | |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
NSString *userName = @"Hank"; | |
BOOL isActive = YES; | |
[defaults setObject:userName forKey:kUserName]; | |
[defaults setBool:isActive forKey:kIsActive]; | |
} | |
// 清除資料 | |
-(void)clearInfo { | |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
[defaults removeObjectForKey:kUserName]; | |
[defaults removeObjectForKey:kIsActive]; | |
} | |
// 執行 | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
[self saveInfo]; | |
[self loadInfo]; | |
[self clearInfo]; | |
[self loadInfo]; | |
} |