я хотел бы получить данные с сервера, закодированные в формате JSON, чтобы отобразить его, поэтому я использую afnetworking библиотеку, но я получаю ошибку здесь мой кодошибка при получении данных с сервера с помощью Afnetworking
NSURL * url =[NSURL URLWithString:@"http://software-sultan.com/alaa/image_test.php"];
NSURLRequest запрос * = [ Запрос NSURLRequestWURUR: url];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.responseSerializer = [AFJSONResponseSerializer serializer];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
// 3
array = [NSJSONSerialization JSONObjectWithData:responseObject options:kNilOptions error:nil];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
// 4
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error Retrieving Weather"
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alertView show];
NSLog(@"%@",error);
}];
// 5
[operation start];
здесь ошибка
Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo=0x7f920964bff0 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7f920965cc20> { URL: http://software-sultan.com/alaa/image_test.php } { status code: 200, headers {
Connection = "keep-alive";
"Content-Length" = 126781;
"Content-Type" = "text/html";
Date = "Thu, 29 Jan 2015 19:00:55 GMT";
"Keep-Alive" = "timeout=30";
Server = "Apache/2";
"X-Powered-By" = "PHP/5.3.13";
}}, NSErrorFailingURLKey = http://software-sultan.
Возможный дубликат [Запрос не удалось: недопустимый тип содержимого: текст/html с использованием AFNetworking 2.0] (http://stackoverflow.com/questions/19114623/request-failed-unacceptable-content-type-text-html-using -afnetworking-2-0) – glyuck