다음 코드에서보기 컨트롤러의 속성 인 NSMutableArray 'categories'의 값으로 표보기 셀 텍스트를 설정합니다. 그건 잘 작동합니다.IPhone - 배열, 이중 표준에서 NSString 설정!
그러나 다른 메서드에서 똑같은 코드를 시도하면 오류 또는 경고없이 컴파일됩니다.
NSString *categoryName = [categories objectAtIndex:indexPath.row];
NSString *categoryName = [[NSString alloc] initWithString:@"test"];
의미가 있습니다 ... 어떤 아이디어에 : 나는 didSelectRowAtIndexPath 방법에 다음 줄을 변경하는 경우?
// 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];
}
크래시가 무슨 말을합니까? 크래시가 발생했을 때 콘솔에서 '백 트레이스'를 말하고 그 질문에 붙여 넣으면 도움이됩니다. – Surya
그리고 무엇이 *'[categories objectAtIndex : indexPath.row]'입니까? 디버거에서 이것을 보셨습니까? 아니면 그냥 NSLog 디버깅? – Chuck