卻發現
什麼都沒作用直接
- (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
沒有留言:
張貼留言