Note that there are some explanatory texts on larger screens.

plurals
  1. POIPhone - Setting NSString from array, double standards!
    primarykey
    data
    text
    <p>In the following bit of code, I'm setting the table view cell text with a value from the NSMutableArray 'categories' which is a property of my view controller. That works fine.</p> <p>But when I try the exact same code in another method, it crashes (it compiles without errors or warnings). If I change the following line in the didSelectRowAtIndexPath method:</p> <pre><code>NSString *categoryName = [categories objectAtIndex:indexPath.row]; </code></pre> <p>to</p> <pre><code>NSString *categoryName = [[NSString alloc] initWithString:@"test"]; </code></pre> <p>It works... any ideas?</p> <pre><code>// Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } // Configure the cell. NSString *categoryName = [categories objectAtIndex:indexPath.row]; cell.textLabel.text = categoryName; return cell; } // Override to support row selection in the table view. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { printf("User selected row %d\n", [indexPath row] + 1); ButtonsPageViewController *bView = [ButtonsPageViewController alloc]; NSLog(@"created instance of buttonspageviewcontroller"); NSString *categoryName = [categories objectAtIndex:indexPath.row]; NSLog(@"category name set"); bView.selectedCategory = categoryName; NSLog(@"selected category property set"); [self.navigationController pushViewController:bView animated:YES]; NSLog(@"push view controller"); [bView release]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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