Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9069485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:26:27+00:00 2026-06-16T17:26:27+00:00

I am having trouble telling my table view which NSURLRequest it should target. I

  • 0

I am having trouble telling my table view which NSURLRequest it should target. I can get a basic table view to load with a single query, but am trying to make it pull the json string from a different URL if certain segmented controls are active.

These first three lines of code work by themselves

NSString *urlA1 = [NSString stringWithFormat:@"http://www.website.com/json_books.php?
item_id=%@",itemId];

NSURL *urlA2 = [NSURL URLWithString:urlA1];

NSURLRequest *requestA = [NSURLRequest requestWithURL:urlA2];
[[NSURLConnection alloc] initWithRequest:requestA delegate:self];

However, if I include the following three lines after the first three, the tableview loads the json from the first NSURLRequest, then immediately flickers and shows content from the string below:

NSString *urlB1 = [NSString stringWithFormat:@"http://www.website.com/json_movies.php?
item_id=%@",itemId];

NSURL *urlB2 = [NSURL URLWithString:urlB1];

NSURLRequest *requestB = [NSURLRequest requestWithURL:urlB2];
[[NSURLConnection alloc] initWithRequest:requestB delegate:self];

I am pulling the result into the table view with these lines of code:

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse 
*)response
{
    data = [[NSMutableData alloc] init];
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)theData
{
    [data appendData:theData];
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

    items = [NSJSONSerialization JSONObjectWithData:data options:nil error:nil];
    [mainTableView reloadData];
}

Does anyone know why I am unable to specify which NSURLRequest I would like the tableview to target? Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:26:29+00:00Added an answer on June 16, 2026 at 5:26 pm

    Do you Want to Show Data from Both The URL ?

    if yes then You have to take NSMUtableArray and initialize the Array in ViewDidload before Firing the Request. And You have to Add the Objects into the Array from Each URL.

    Example:

    [DataArray addObject:@"Yourdata"];
    
    [Yourtable reloadData];
    

    If You need to Separate the data as per Segmented Control then Save Your data in Separate Array.

    MyfirstArray= @"Data from URL 1";
    
    MySecondArray= @"Data from URL 2";
    
    
    -(IBAction)SegmentChange:(Id)sender
    {
    if(segmented.selectedSegmentIndex==0)
    
    {
    items=MyfirstArray;
    
    [mytable reloadData];
    
    }
    
    else
    
    {
    items=MysecondtArray;
    
    [mytable reloadData];
    }
    
    }
    

    Also You can take Switch statement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having some trouble telling twig which template to load. I have a
having some trouble with hitTestObject and now Flash is telling me it can't convert
Having trouble understanding how to filter an images table by tag information in a
I'm having trouble telling Regex to ignore any escape sequences. Here is some example
I'm having trouble building gdlib. As far as I can tell, zlib, png and
I'm having trouble with the <target> tag in my WPF project. What I'm trying
I'm having trouble trying to get ValueInjector to map my objects correctly. This is
Having trouble trying to get this simplified. Still somewhat new to jQuery so please
Having trouble with each function... Will try to explain by example... In my code,
Having trouble with an .htaccess file on WAMP. Works on the live server, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.