开发者

iphone+webservice

开发者 https://www.devze.com 2023-02-21 21:55 出处:网络
I have one web service but when i pass multiple word like new erra it will return 0 bytes in NSMutuabledata

I have one web service but when i pass multiple word like new erra it will return 0 bytes in NSMutuabledata my method is like

NSString *ur开发者_运维问答l = [NSString stringWithFormat:@"%@?url='%@'&word=%@",apiUrl,self.urlString,searchword];
NSMutableData *Data = [appDelegate initRequestWithPost:url withPostData:nil];

where searchword is new era Thanks


I think you have to escape the url string. Try using somthing like this.

+(NSString *)escapeURL:(NSString *)text{
CFStringRef tmp=CFURLCreateStringByAddingPercentEscapes(
                                                        NULL,
                                                        (CFStringRef)text,
                                                        NULL,
                                                        (CFStringRef)@"!*'\"();:@&=+$,/?%#[]% ",
                                                        kCFStringEncodingUTF8 );
NSString * encodedString = (NSString *)tmp;
return encodedString;

}

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号