1

I am new in ios. I am working in a application in which i need to post some data in nameValuepair so I used NSDictionary to crate a name value pair but with NSDictionary there is issue on server side to parse posted data. Is there any way to create NameValuePair in iOS 6 like in android there is a entity called BasicNameValuePair .

user2298296
  • 91
  • 1
  • 4

1 Answers1

0

You can use this code,

   NSURL *Url = [NSURL URLWithString:@"http://yourURLaddress"];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:Url
                                             cachePolicy:NSURLRequestUseProtocolCachePolicy
                                         timeoutInterval:60.0];

    NSURLConnection *MyConnection= [[NSURLConnection alloc] initWithRequest:request 
                                                                 delegate:self];
    [request setHTTPMethod:@"POST"];
    NSString *postString = @"id=2315645&name=Ram&deviceId=3453564666643634";
    [request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];
    [MyConnection start];
Jageen
  • 6,345
  • 2
  • 37
  • 56
  • thanks for reply. Actualy in android version of same application data is posted in the form of BasicNameValuePair which work fine but in ios I used JSON, NSDictionary and also your idea but its not vorking. please help me. – user2298296 Jul 17 '13 at 09:10
  • which type of problem you get on server side? – Jageen Jul 17 '13 at 09:19
  • Is this post is useful ? http://stackoverflow.com/questions/12427804/sending-parameters-to-php-script-in-ios – Jageen Jul 17 '13 at 09:24
  • I don't have access of server but may be some parsing issue because it work well for android version. – user2298296 Jul 17 '13 at 09:47
  • Have you checked format of data passed from application using application like wireshark? because i believe there should not be problem in code. – Jageen Jul 17 '13 at 09:55