I'm trying to start this operation and its not even getting to the NSLOG. I guess its something with my stringUrl, maybe its not suppose to work like this?
This is my code:
NSString *stringUrl = [[NSString alloc]initWithFormat:@"http://example.com/add_user.php?username=%@&password=%@&country=%@&email=%@",[self.usernameTextField text],[self.passwordTextField text], countrySelected, [self.emailTextField text]];
NSURL *url = [NSURL URLWithString:stringUrl];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSDictionary *dict = JSON;
NSLog(@"IP Address: %@", [JSON valueForKeyPath:@"item"]);
} failure:nil];
[operation start];
Edit: this is what i got from the failure block:
Error Domain=AFNetworkingErrorDomain Code=-1016 "Expected content type {( "text/json", "application/json", "text/javascript" )}, got text/html" UserInfo=0xa2b4300 {NSLocalizedRecoverySuggestion={"type":"1","item": "User added successfully."} , AFNetworkingOperationFailingURLRequestErrorKey=http://EXAMPLE.com/add_user.php?username=aaasafasfasf&password=aaa&country=Angola&email=aaaasfasfasfasfasf>, NSErrorFailingURLKey=http://EXAMPLE.com/add_user.php?username=aaasafasfasf&password=aaa&country=Angola&email=aaaasfasfasfasfasf, NSLocalizedDescription=Expected content type {( "text/json", "application/json", "text/javascript" )}, got text/html, AFNetworkingOperationFailingURLResponseErrorKey=}