Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

benhowdle89

macrumors newbie
Original poster
Oct 18, 2010
4
0
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?
 
It is very difficult to debug problems without seeing the code. Are you using a synchronous API for the http transaction?
 
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!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.