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

  • Home
  • SEARCH
  • 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 6918123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:49:07+00:00 2026-05-27T09:49:07+00:00

So I am trying to pass a url between views. I was thinking that

  • 0

So I am trying to pass a url between views. I was thinking that the following code will stomp on whatever is in @”url” every time the user makes a selection from the tableview. What actually happens is that the first selection is always being returned and is never stomped on. Hmmmm, maybe it is me? Any ideas? Thanks.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0)
    {
        [self saveToUserDefaults:@"http://url1"];
        [self.navigationController pushViewController:self.webController animated:YES];
    }
    else if (indexPath.row == 1)
    {
        [self saveToUserDefaults:@"http://url2"];
        [self.navigationController pushViewController:self.webController animated:YES];
    }
}

-(void)saveToUserDefaults:(NSString*)myString
{
    NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];

    if (standardUserDefaults) 
    {
        [standardUserDefaults setObject:myString forKey:@"url"];
        [standardUserDefaults synchronize];
    }
}

On the receiving end:

-(NSString*)retrieveFromUserDefaults
{
    NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
    NSString *val = nil;

    if (standardUserDefaults) 
        val = [standardUserDefaults objectForKey:@"url"];

    return val;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    NSString *url = self.retrieveFromUserDefaults;
    [self handleURLRequest:url];
}
  • 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-05-27T09:49:08+00:00Added an answer on May 27, 2026 at 9:49 am

    viewDidLoad is only called when your view is initially loaded from the xib file. If you pop and re-push the view controller then the method won’t be executed again unless you’ve received low memory warnings.

    Move the code to viewWillAppear which is guarantee to be called every time your view, well, appears.

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

Sidebar

Related Questions

I'm trying to pass an encrypted query string to another URL. The following code
I'm trying to pass a userId (string) in the URL which will be passed
I am trying to pass data between two activities that are inside of tabs.
I'm trying to pass a string parameter in MVC3. The URL that gets generated
I'm trying to pass URL variables to my PHPExcel PHP script, so that i
I'm trying to get php to automatically pass the session ID via url, even
I'm trying to pass one method to another in elisp, and then have that
I'm trying to pass a complex object (that can be serialized, if that helps)
I'm trying to pass a null value for the first parameter in the code
I'm trying pass in a url as a paramter to my controller like this:

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.