воскресенье, 11 августа 2013 г.

Passing Cyrillic characters as a URL parameter


NSString *str = textField.text; 
 
NSString *serverAddress = SERVER_ADDRESS;
 
NSString *restMethodAddress = @"/rest/someResource/someMethod";
 
NSString *encodeString = 
[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
 
NSString *param = [NSString stringWithFormat:@"?charSequence=%@", encodeString];
 
NSMutableString *fullRequestAddress = [NSMutableString stringWithString:serverAddress];
[fullRequestAddress appendString:restMethodAddress];
[fullRequestAddress appendString:likeCitiesParam];
 
NSURL *url =[NSURL URLWithString:fullRequestAddress];
 
NSMutableURLRequest *theRequest = [NSMutableURLRequest 
requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60];
 
[theRequest setHTTPMethod:@"GET"];
 
NSURLConnection connection = 
[[NSURLConnection alloc] initWithRequest:theRequest delegate:self ];

Комментариев нет:

Отправить комментарий