我在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