Translate

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!

2013年2月18日 星期一

xcode 4.6 不能實機測試


xcode給我的錯誤訊息
file is universal (3 slices) but does not contain a(n) armv7s slice: /Users/Sundance/Downloads/FBShareSDK3/FacebookSDK.framework/FacebookSDK for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)

後來解決方法
專案的TARGETS的Build Settings修改
Valid Architectures的值
預設為armv7 armv7s
改成armv7 armv6
就可以安裝到實機上了

2013年2月4日 星期一

NSURL is (null)

有次在做client跟server的溝通使用ASIHTTPRequest做資料傳輸
卻發現
什麼都沒作用直接
- (void)requestFailed:(ASIHTTPRequest *)request
還跑去叫server的人來看php為什麼資料會吐不出來
也跑了error的錯誤來看
Error Error Domain=ASIHTTPRequestErrorDomain Code=5 "Unable to create request (bad url?)" UserInfo=0x8b599e0 {NSLocalizedDescription=Unable to create request (bad url?)}
後來仔細檢測
發現再
NSString to NSURL這邊出了問題而且很奇怪的是
一個中文字不會出現這樣的問題真是妙了

NSString *url_str = [NSString stringWithFormat:@"%@%@&Keyword=%@", area_cate_poi_str, AppDelegate.lag_id, searchbar.text]; NSLog(@"getPoiServer url_str is %@", url_str); NSURL *url = [NSURL URLWithString:url_str]; NSLog(@"url is %@", url); ASIHTTPRequest *request_poi = [ASIHTTPRequest requestWithURL:url]; [request_poi setDelegate:self]; [request_poi startAsynchronous];
2013-02-04 17:10:26.634 Tainan[17738:207] getPoiServer url_str is http://202.3.189.133/tainan/API/poi.php?type=title&lang_id=1&Keyword=台南 2013-02-04 17:10:26.634 Tainan[17738:207] url is (null)
後來發現NSString to NSURL會發生這樣的狀況 才知道是本身語法的問題跟sever沒關係 後來才知道要先幫NSString轉成UTF8格式
NSString *url_str = [NSString stringWithFormat:@"%@%@&Keyword=%@", area_cate_poi_str, AppDelegate.lag_id, searchbar.text]; url_str = [url_str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSURL *url = [NSURL URLWithString:url_str]; NSLog(@"url url_str is %@", url); ASIHTTPRequest *request_poi = [ASIHTTPRequest requestWithURL:url]; [request_poi setDelegate:self]; [request_poi startAsynchronous];
2013-02-04 17:20:40.530 Tainan[17772:207] getPoiServer url_str is http://202.3.189.133/tainan/API/poi.php?type=title&lang_id=1&Keyword=台南 2013-02-04 17:20:40.530 Tainan[17772:207] url is http://202.3.189.133/tainan/API/poi.php?type=title&lang_id=1&Keyword=%E5%8F%B0%E5%8D%97

Ad Hoc利用html安裝

http://esrimobile.blogspot.tw/2012/10/making-release-build-for-ad-hoc.html

http://mobiledevelopertips.com/xcode/distribute-ad-hoc-applications-over-the-air-ota.html

http://aaronparecki.com/articles/2011/01/21/1/how-to-distribute-your-ios-apps-over-the-air

重點再

note: in my case I am using an Microsoft server and I had to add the corresponding MIME Types for the .ipa and .plist. (no screen shots, sorry)

  1. Go to IIS Manager
  2. Locate you web site folder
  3. Right click and select Properties
  4. Open HTTP Headers tab
  5. Click on MIME Types button at the bottom
  6. Click New... button and add these two
    1. .ipa application/octet-stream
    2. .plist text/xml

Now, on your device, navigate to the page and download and install the app.