0
votes

This is my code for requesting a JSON:

[AFJSONRequestOperation addAcceptableContentTypes:[NSSet setWithObject:@"text/html"]];

AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request


                                  success: ^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON){


                                      NSArray *jsonArray =[JSON valueForKey:@"posts"];

                                      [self postsToAnnotations:[self jsonToPosts:jsonArray] andUserLocationLat:lat Lon:lon];


                                  }

                                  failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON){
                                      NSLog(@"response %@",JSON);

                                      NSLog(@"Failed %@",error);

                                      [_activityView removeFromSuperview];


}];

[operation start];
  }

It's working fine on simulator for iPhone 5 and in my device (iphone 4) I am getting this error: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo=0x208b9a80 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

1
This has absolutely nothing to do with Xcode. Apart from that, did you read the error message? It's pretty clear from it what the problem is and it's even telling you how you can resolve it.user529758

1 Answers

0
votes

The problem was with the reply of the server which I was not able to see because I was using AFJSONRequestOperation. After sending the same request AFHTTPRequestOperation I was able to see the reply of the server using "result" string.