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 .
Asked
Active
Viewed 615 times
1
-
what you want pass here? – Balu Jul 17 '13 at 06:15
-
I need to post something like :- [id=2315645, name=Ram, deviceId=3453564666643634] – user2298296 Jul 17 '13 at 06:37
-
You can also use JSON in iOS, here is an example of it,http://www.raywenderlich.com/5492/working-with-json-in-ios-5 – Jageen Jul 17 '13 at 08:27
1 Answers
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
-
-
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