Set Navigation.Title before http url sent

Discussion in 'iOS Programming' started by benhowdle89, Oct 23, 2010.

  1. benhowdle89 macrumors newbie

    Joined:
    Oct 18, 2010
    #1
    I have an app where the initial view is a table, when i click on the row, i want to take the row value and stick it as the navigation.title on the next view, but then i also want to take the row value and perform a http connection where i send the value up to a php page, however when i put this method (the http) in the viewDidLoad, the parameter of the nav.title isnt being sent! Is there any way to set the nav title before it sends the http url?

    I'm using this NSString *navTitle = self.navigationItem.title; and inserting this into NSURL *address = [NSURL URLWithString:[NSString stringWithFormat:mad:"http://www.twostepmedia.co.uk/json.php?q=%@",navTitle]];

    Both of those are in the viewDidLoad method but someone mentioned about a viewWillAppear? That might be the problem?
     
  2. ianray macrumors 6502

    Joined:
    Jun 22, 2010
    Location:
    @
    #2
    It is very difficult to debug problems without seeing the code. Are you using a synchronous API for the http transaction?
     
  3. benhowdle89 thread starter macrumors newbie

    Joined:
    Oct 18, 2010
    #3
    DetailViewController.m

    Code:
    - (void)viewDidLoad {	
    	[super viewDidLoad];
    	NSString *navTitle = self.navigationItem.title;
    	NSString *stalklabel = self.labelforurl.text;
    	NSLog(@"%@", stalklabel);
    	NSURL *address = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.twostepmedia.co.uk/json.php?q=%@",stalklabel]];
    	responseData = [[NSMutableData data] retain];	
    	NSURLRequest *request = [NSURLRequest requestWithURL:address];
    	[[NSURLConnection alloc] initWithRequest:request delegate:self];
    	
    	//NSString *address = [NSString stringWithFormat:@"http://www.twostepmedia.co.uk/json.php?q=%@",na];
    	//[self initiateRequest:address];
    	//NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:address]];
    	
    	//[[NSURLConnection alloc] initWithRequest:request delegate:self];   
    
    }
    
    RootViewController.m

    Code:
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    	[tableView deselectRowAtIndexPath:indexPath animated:YES];
    	//Initialize the detail view controller and display it.
    	DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:[NSBundle mainBundle]];
    	[self.navigationController pushViewController:dvController animated:YES];
    	NSManagedObject *managedObject = [self.fetchedResultsController objectAtIndexPath:indexPath];
    	dvController.navigationItem.title=[[managedObject valueForKey:@"data"] description];
    	dvController.labelforurl.text = [[managedObject valueForKey:@"data"] description];
    	[dvController release];
    	dvController = nil;
    }
    
    No, its a PHP page i wrote which simply receives data via GET and returns whatever back to the app in json format!
     
  4. ianray macrumors 6502

    Joined:
    Jun 22, 2010
    Location:
    @
    #4
    What is the output of this?
    Code:
    NSLog(@"%@", stalklabel);
     
  5. benhowdle89 thread starter macrumors newbie

    Joined:
    Oct 18, 2010
  6. ianray macrumors 6502

    Joined:
    Jun 22, 2010
    Location:
    @
    #6
    You haven't included enough code for anyone to speculate...
     

Share This Page