2

I need to pass a search query where I have an array of string Ids and i want to check if these ids exist on server on not. I am most curious about the performance of my server so i want it to use minimum resources

here is the code i am using

myContactIds = NSMutableArray which contains lets say 1000 strings of ids

NSString *queryString = myUrl?=array=NEED_TO_SEND_ARRAY_HERE ;


 [Utilities responseFromURL:[NSURL URLWithString:queryString] completionBlock:^(NSString *response, NSError *errorString)
     {

         [self.myTable reloadData];
         [self.indicator stopAnimating];
     }];

Firstly how can i pass an array with my url so that it can be read on my PHP server side code Secondly, How can I use that array to query on server side if the database contains the ids and sends back as response, the ids that exists in database

P.S If i can get answer without using any external library its better since i want to learn.

Muhammad Umar
  • 11,391
  • 21
  • 91
  • 193

1 Answers1

0

do you want to pass the strings in the url? for example:
www.myUrl.com?array=string1%7Cstring2%7Cstring3

if so, you can use componentsJoinedByString:

NSArray *myArray = @[@"string1", @"string2", @"string3"];
NSString *stringFromArray = [myArray componentsJoinedByString:@"%7C"];

and then you can use that string in your url. and then of course you will haev to parse the substrings out of the url on your webserver.

however, it would probably be much easier to embed this array in the HTTP body of the web request. You can create a JSON blob from the array of strings. and then stuff the JSON into the HTTP body of your request.

the solution that you use is obviously going to be specific to your exact needs.

bturner
  • 514
  • 3
  • 9
  • alright, lets say i json encode on client side but i am not sure what to do on server side in php. i know obj C but not php that much. That is the problem – Muhammad Umar Apr 14 '13 at 03:51
  • im not a php guy. could probably walk you through it in Node.js or something. but it would probably be best to pick a server side language and then just go grab a book on it. – bturner Apr 16 '13 at 13:29