0

I have created a page where i need to use two API in the same page, but i have no idea how to call another API in the same page for another URL. I have posted my code below. I have already used an API for displaying images in a collection view now the other one is needed to be used in a scroll view displaying maximum 18 images and minimum is zero.I am posting my code below for the 1st API call-

NSURL *url = [NSURL URLWithString:@"http://tattoosingles.net/webservice/tattoosingles.php"];



 NSMutableURLRequest *request =[[NSMutableURLRequest alloc] initWithURL:
                               url];



NSString *postData = [[NSString alloc] initWithFormat:@"id=578&call=0"];


[request setCachePolicy:NSURLRequestUseProtocolCachePolicy];

[request setHTTPMethod:@"POST"];
[request setValue:@"application/x-www-form-urlencoded; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:[postData dataUsingEncoding:NSUTF8StringEncoding]];

_connection = [[NSURLConnection alloc] initWithRequest:request   delegate:self];


- (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse *)response
{
NSLog(@"Did Receive Response %@", response);

_responseData = [[NSMutableData alloc]init];

}
- (void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data
{
//NSLog(@"Did Receive Data %@", data);
//NSLog(@"%@",data);
[_responseData appendData:data];
- (void)connection:(NSURLConnection*)connection didFailWithError: (NSError*)error
 {

  NSLog(@"Did Fail");
//    [_activityView stopAnimating];
//    _activityView.hidden=YES;

[[UIApplication sharedApplication] endIgnoringInteractionEvents];



 - (void)connectionDidFinishLoading:(NSURLConnection *)connection
 {
NSLog(@"Did Finish");



NSError * error = nil;
_responsedic = [NSJSONSerialization JSONObjectWithData:_responseData options:kNilOptions error:&error];

After using the first API my page looks like this-

Using 1st API

And another API i have to use for the above hexagonal images. Please help!!

Bhavin Ramani
  • 3,221
  • 5
  • 30
  • 41
pri
  • 87
  • 11
  • Please see this http://stackoverflow.com/questions/31343589/best-way-to-handle-multiple-nsurl-connections – Ekta Padaliya Jul 11 '16 at 10:32
  • its a bit complicated for me but i will give a try...thanks!! – pri Jul 11 '16 at 10:42
  • You can also use "AFNetworking Framework" https://github.com/AFNetworking/AFNetworking It also manages the network of the app it will give you callbacks through blocks. – Darshan Mothreja Jul 11 '16 at 11:56

0 Answers0