0

UITableView用户UIView点击UITableViewCell. 我想让推送视图的标题成为推送视图来自的单元格中的文本。我正在尝试声明NSUInteger何时选择该行以创建使用ObjectatIndex的字符串。我的理解是objectAtIndex接受 type NSUInteger。这对我来说真的没有用。

(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
//get index number
NSNumber *selRow = [[NSNumber alloc] initWithInteger:indexPath.row];
NSUInteger rows = (NSUInteger)selRow;
NSLog(@"%@",rows); //this outputs correctly
NSString *pushTitle = [[self.WorkoutListArray objectAtIndex:rows] stringValue];  //error on this line

//declares a new view controller when something is selected -- uses story board to initialize
WorkoutPushViewController *newView = [self.storyboard instantiateViewControllerWithIdentifier:@"WorkoutPush"];

//when selected a new view is pushed
[self.navigationController pushViewController:newView animated:YES];

//adds a title to the push view
newView.title = pushTitle;
}
@end

我得到一个

NSRangeExcpetion 错误

当我尝试声明字符串时。我尝试了几种方法来声明NSStringfrom theNSArray但还没有运气。我希望我的问题很清楚:)

4

1 回答 1

0

我忘记了我试图打印的对象具有名称和日期属性。(抱歉犯了那个愚蠢的错误)下面的代码正是我想要它做的。

NSString *pushTitle = [[self.WorkoutListArray objectAtIndex:indexPath.row] workoutName];

//set the title
newView.title = pushTitle;

感谢您的帮助和耐心。

于 2015-06-10T06:02:03.770 回答