1つの方法はそこにあります、あなたはポストリクエストによってjsondataを解析することができます
-(void)callWebserviceList
{
spinner.hidden=NO;
NSString *bodyData = @"code_request=monuments_list&asi_id=1";
NSMutableURLRequest *postRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://asicircles.com/server_sync.php"]];
// Set the request's content type to application/x-www-form-urlencoded
[postRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
// Designate the request a POST request and specify its body data
[postRequest setHTTPMethod:@"POST"];
[postRequest setHTTPBody:[NSData dataWithBytes:[bodyData UTF8String] length:strlen([bodyData UTF8String])]];
connection1 = [NSURLConnection connectionWithRequest:postRequestデリゲート:自己];
if(connection1 !=nil)
{
////NSLog(@"%@",postRequest);
}
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
if ([connection isEqual:connection1 ])
{
[responseData setLength:0];
}else if ([connection isEqual:connection2 ])
{
[responseData1 setLength:0];
}
}-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
if ([connection isEqual:connection1 ])
{
[responseData appendData:data];
}else if ([connection isEqual:connection2 ])
{
[responseData1 appendData:data];
}
//**check here for responseData & also data**
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
NSLog(@"%@",[NSString stringWithFormat:@"Connection failed: %@", [error description]]);
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
if ([connection isEqual:connection1 ])
{
spinner.hidden=YES;
NSError *error;
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
NSMutableArray *arrdata=[json objectForKey:@"message"];
NSLog(@"code is%@", json);
for (int i=0; i< arrdata.count; i++)
{
[arrDetails addObject:[[arrdata objectAtIndex:i]objectForKey:@"details"]];
[arrImageUrl addObject:[[arrdata objectAtIndex:i]objectForKey:@"image"]];
[arrLat addObject:[[arrdata objectAtIndex:i]objectForKey:@"lat"]];
[arrLongi addObject:[[arrdata objectAtIndex:i]objectForKey:@"longi"]];
[arrName addObject:[[arrdata objectAtIndex:i]objectForKey:@"name"]];
[arrLoc addObject:[[arrdata objectAtIndex:i]objectForKey:@"location"]];
[arrID addObject:[[arrdata objectAtIndex:i]objectForKey:@"id"]];
NSLog(@"code is%@",[[arrdata objectAtIndex:i]objectForKey:@"details"]);
NSLog(@"code is%@",[arrImageUrl objectAtIndex:i]);
}
if (arrName.count > 0)
{
[self addscrollView];
}
}else if ([connection isEqual:connection2 ])
{
}
}