Note that there are some explanatory texts on larger screens.

plurals
  1. POUIWeb view loads wrong address from array
    text
    copied!<p>I have an app that populates a table and pushes a web view when cell in selected. I have two problems</p> <ol> <li><p>The web view pushs and loads however the web address that loads is incorrect. i.e first cell should load web address one but it appears to be random. The web addresses come from an array. </p></li> <li><p>The web view does not push on the first cell selected every time the app is launched.</p></li> </ol> <p>Heres my code. Any help would be appriecated.</p> <p>Table view</p> <pre><code>- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [self setupArray]; [super viewDidLoad]; // Do any additional setup after loading the view. } -(void)setupArray { webAddress = [[NSMutableDictionary alloc]init]; [webAddress setObject:@"http://www.google.com.au" forKey:@"one"]; [webAddress setObject:@"http://www.finddrinkdine.com.au" forKey:@"Two"]; [webAddress setObject:@"http://www.kingsgroversl.com.au" forKey:@""three"]; [webAddress setObject:@"http://www.yahoo.com.au" forKey:@"Four"]; [webAddress setObject:@"http://www.scu.edu.au" forKey:@"Five"]; [webAddress setObject:@"http://www.whitenow.com.au" forKey:@"Six"]; menuItems = [webAddress allKeys]; } -(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [webAddress count]; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *simpleTableIdentifier = @"cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier]; } cell.textLabel.text = [menuItems objectAtIndex:indexPath.row]; return cell; } </code></pre> <p>Detail View</p> <pre><code>- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { return self; } -(void)viewWillAppear:(BOOL)animated { NSURL *url = [NSURL URLWithString:webAddress]; NSURLRequest *req = [NSURLRequest requestWithURL:url]; [viewWeb loadRequest:req]; [super viewWillAppear:animated]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload