我在didSelectRowAtIndexPath方法委托方法如下代码:问题与指针
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
Exercise *exerciseView = [[Exercise alloc] initWithNibName:@"Exercise" bundle:nil]; //Makes new exercise object.
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSString *str = cell.textLabel.text; // Retrieves the string of the selected cell.
exerciseView.exerciseName.text = str;
NSLog(@"%@",exerciseView.exerciseName.text);
[self presentModalViewController:exerciseView animated:YES];
}
在此,笔者尝试采取选定单元格的文本,以及IBOutlet中的UILabel exerciseName设置该字符串。
我的方法编译,但是当我运行NSLog,它将它设置为str后打印UILabel的textvalue,它将返回null。我觉得这是一个指针问题,但似乎无法理解它。任何人都可以澄清事情吗?
当你NSLog str你没有得到空?你在使用ARC吗? – shein 2012-04-23 02:58:53
请在你的其他类似问题中看到我的评论。 – danh 2012-04-23 03:00:53