How to retrieve json data from server side using POST method in objective c?

I'm trying to retrieve json data from server side using POST method using objective C, but i don't know how to do it. I'm new to xcode. so plz help me. Thanks !

This is my program,


-(NSMutableDictionary*)readFromFile:(NSString*)file

{

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://xyz.com/"

NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];

NSString*jsonString = [[NSString alloc] initWithData:response encoding:NSASCIIStringEncoding];

NSMutableDictionary*jsonDict = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];

//this part retrieves data stored inside the project folder.

/* NSString*filePath = [[NSBundle mainBundle] pathForResource:file ofType:@"json"];

NSData*data = [NSData dataWithContentsOfFile:filePath];

NSString*jsonString = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];

NSMutableDictionary*jsonDict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];*/

return jsonDict;

}

First a fall u have to check that data is in Array or Dictionary.. Then do further coding.


e.g.,

// create connection

NSURL *url = [NSURL URLWithString:@"http:/ ......"];

NSData *jsonData = [NSData dataWithContentsOfURL:url];

NSDictionary *jsonDic = [NSJSONSerialization JSONObjectWithData:jsonData options:kNilOptions error:nil];


// Then save your response and set object.

NSDictionary *json = [jsonDic objectForKey:@"response"];

self.labelText.text = [json objectForKey:@"firstname"];

How to retrieve json data from server side using POST method in objective c?
 
 
Q