ios - Loop through array elements -


i developing 1 app,in have used send contact numbers server through webservices.here contact numbers array,but how can send contact array on for-loop.here services link .

http://project.in/project-contacts.php 

parameter contact_numbers[]

here below tried code

nsstring *postvararraystring = @"";     nsstring *separator = @"?";     (int i=0; i<[_numberarray count]; i++) {         if (i>0) {             separator = @"&";         }         postvararraystring = [nsstring stringwithformat:@"%@%@myarray[]=%ld", postvararraystring, separator, (long)[[_numberarray objectatindex:i] integervalue]];     }      // url     nsurl *url = [nsurl urlwithstring:[nsstring stringwithformat:                                        @"http://project.in/project-contacts.php"                                        @"%@"                                        , postvararraystring]                   ];      nslog(@"qq=%@", [url absolutestring]); 

here how can send array of contacts through webservices.can please suggest me how can send ,thank you.

send dictionary parameter php script grabs parameters $_post variable.

example using afnetworking library.

nsarray *keys = [nsarray arraywithobjects: @"key1", @"key2", nil]; nsarray *values = [nsarray arraywithobjects: @"value1", @"value2", nil]; nsdictionary *parameters = [nsdictionary dictionarywithobjects: values keys: keys];  afhttpclient *client = [[afhttpclient alloc] initwithbaseurl[nsurl urlwithstring:@"your  server url"]; nsurlrequest *request = [client requestwithmethod:@"post" path:@"path" parameters:parameters];  afjsonrequestoperation *operation = [afjsonrequestoperation jsonrequestoperationwithrequest:request success:^(nsurlrequest *request, nshttpurlresponse *response, id json) { } failure:^(nsurlrequest *request, nshttpurlresponse *response, nserror *error, id json) { }]; [operation start]; 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -