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];
}
ここでは、選択したセルのテキストを取得し、IBOutletUILabelのexerciseNameをその文字列に設定しようとしています。
私のメソッドはコンパイルされますが、strに設定した後にUILabelのテキスト値を出力するNSLogを実行すると、nullが返されます。これはポインタの問題のように感じますが、理解できないようです。誰かが物事を明確にすることができますか?