ASIHTTPRequest y letras cirílicas
Frecuentes
Visto 311 veces
0
Buen día, estoy trabajando con ASIHTTPRequest y tengo un problema con las letras cirílicas en la solicitud.
Tuve esta solicitud:
self.getUsersFromSearchRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@&text=%@&count=20", SEARCH_FOR_USER, searchBar.text]]];
[self.getUsersFromSearchRequest setDelegate:self];
[self.getUsersFromSearchRequest startAsynchronous];
Después de esto tengo solicitudTerminada: y solicitud fallida: métodos:
- (void)requestFinished:(ASIHTTPRequest *)request {
self.dictionary = [NSJSONSerialization JSONObjectWithData:[request responseData] options:NSJSONWritingPrettyPrinted error:nil];
if([request isEqual:self.getUsersFromSearchRequest]) {
if ([[self.dictionary objectForKey:@"response"] isKindOfClass:[NSArray class]]) {
self.resultSearchUser = [self.dictionary objectForKey:@"response"];
[self.searchDisplayController.searchResultsTableView reloadData];
}
self.searchResultsTable.hidden = NO;
[MBProgressHUD hideHUDForView:self.view animated:YES];
}
}
- (void)requestFailed:(ASIHTTPRequest *)request {
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:NSLocalizedString(@"Internet Connection Error Alert Title", @"This is the Internet Connection Error Alert Title") message:NSLocalizedString(@"Internet Connection Error Alert Message Text", @"This is the Internet Connection Error Alert Message Text") delegate:nil cancelButtonTitle:NSLocalizedString(@"Internet Connection Error Alert Cancel Button Title", @"This is the Internet Connection Error Alert Cancel Button Title") otherButtonTitles:nil];
[alertView show];
}
Cuando ingreso letras latinas en el campo de texto de búsqueda, todo va bien, pero después de ingresar letras cirílicas, estoy ingresando inmediatamente solicitud fallida:. ¿Qué está mal?
Gracias de antemano!
1 Respuestas
2
¡Problema resuelto! ¡Debe codificar la cadena URL! Como esto:
self.getUsersFromSearchRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:[[NSString stringWithFormat:@"%@&text=%@&count=20", SEARCH_FOR_USER, searchBar.text] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
Respondido 24 ago 12, 09:08
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas objective-c xcode networking request asihttprequest or haz tu propia pregunta.