DetailViewController.m
代码:
- (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
代码:
- (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;
}
NSLOG的输出是“标签”?因此,当我尝试将其嵌入到URL中时,它只返回“Label”??
有什么想法吗?
答案 0 :(得分:0)
在InterfaceBuilder中或代码中的某处,labelforurl的值为Label。更改此值以获得不同的结果。如果要在IB中更改它,请使用UITextField而不是UIlabel。