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;
}