Translate

2013年3月7日 星期四

os x10.8 找不到Library資料夾

原來發現是被系統所隱藏了起來
在終端機上
chflags nohidden ~/Library/

如果想要在隱藏起來就輸入
chflags hidden ~/Library/

2013年2月25日 星期一

NSComparisonResult


NSOrderedAscending means: The left operand is smaller than the right operand.
左邊小於右邊

NSOrderedDescending means the opposite: The left operand is greater than the right operand.
左邊大於右邊
    
Equality is represented by NSOrderedSame: The two operands are equal.
兩邊相等

Hide and show activity indicator in statusbar


//    show
    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
//    hide
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

2013年2月24日 星期日

nested pop animation can result in corrupted navigation bar

這個問題發生在

- (void)viewWillAppear:(BOOL)animated {};
或
- (void)viewDidAppear:(BOOL)animated {};
所以必須要注意不要在這
Calling pushViewController before viewDidAppear is unsafe.

2013年2月22日 星期五

NSDate is not correct

本來抓時間我都用很簡單的
NSDate *now_date = [NSDate date];
卻發現抓出來的時間少了8個小時
之後發現原來要加上
NSLocal

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setLocale:[NSLocale currentLocale]]; [dateFormatter setDateFormat:@"yyyy-mm-dd HH:mm:ss Z"]; NSLog(@"結束時間 is %@",[dateFormatter stringFromDate:[NSDate date]]);

2013年2月21日 星期四

NSDateFormatter to NSDate to NSString are null

在解析RSS發生的問題
在RSS裡面的key值pubdate是Wed, 20 Feb 2013 00:00:00 GMT
這樣的表示方式
但是業主希望能呈現為2013-02-20
神奇的是
我在模擬器上可以取得轉換後的值
但是時機上卻不可以
最後才發現一個重點
就是要在一開始轉換的時候要加上時區

NSString *date_str = [id_news objectForKey:@"pubdate"]; NSLog(@"date_str is %@",date_str); NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; [dateFormatter setLocale:usLocale]; [dateFormatter setDateFormat:@"EEE, dd MMMM yyyy HH:mm:ss Z"]; [dateFormatter dateFromString:date_str]; NSDate *date = [dateFormatter dateFromString:date_str]; NSLog(@"date is %@",date); NSDateFormatter *form = [[NSDateFormatter alloc] init]; [form setDateFormat:@"yyyy-MM-dd"]; NSString *dateStr = [NSString stringWithFormat:@"%@", [form stringFromDate:date]]; NSLog(@"dateStr is %@",dateStr); 2013-02-21 16:42:00.943 Tainan[3246:4d1b] date_str is Wed, 20 Feb 2013 00:00:00 GMT 2013-02-21 16:42:00.948 Tainan[3246:4d1b] date is 2013-02-20 00:00:00 +0000 2013-02-21 16:42:00.950 Tainan[3246:4d1b] dateStr is 2013-02-20

2013年2月19日 星期二

xcode 4.6 libxml2 can’t find


So, I upgraded XCode to 4.6 some time back and now it stops compiling my project. I am using Matt Gemmell’s twitter engine and it uses xmlreader.h. I checked my header search paths, then I checked my linker settings and found that libxml2.dylib was missing, so I removed it added it back again. But still no luck!
This is what fixed it for me finally.
  1. in XCODE go to Project–>Target–>Build Settings
  2. In the search box, type “header search paths”
  3. Either add or update libxml settings to $(SDKROOT)/usr/include/libxml2.
That should fix it!