0

まず、私は Objective-C と iOS プログラミング全般にかなり慣れていないので、これに対する答えが皆さんにとって明らかである場合は、ご容赦ください。

だから私は今、Apress Beginning iOS 5 book を読んでいて、ストーリーボードについての第 10 章で、例の 1 つを実行しようとすると、次の問題に遭遇します。

私が理解しているように、このコード ブロックはタスクのテキストをリストから次のページのテキスト入力フィールドに渡すことになっています。これは本からのコードですが、コードをビルドして実行しようとすると、次のエラーが表示されます。

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 
    UIViewController *destination = segue.destinationViewController;

    if ([destination respondsToSelector:@selector(setDelegate:)]) { 
        [destination setValue:self forKey:@"delegate"];
    }

    if ([destination respondsToSelector:@selector(setSelection:)]) {
        // prepare selection info
        NSIndexPath *indexPath = [self.tableView indexPathForCell:sender]; // Error on this line
        id object = [self.tasks objectAtIndex:indexPath.row];
        NSDictionary *selection = [NSDictionary dictionaryWithObjectsAndKeys:
                                  indexPath, @"indexPath", 
                                  object, @"object",
                                  nil];
        [destination setValue:selection forKey:@"selection"]; 
    }
}

ちなみに、私はXcode 4.4を実行しています。どんな助けでも大歓迎です。ありがとう。

よろしく、 ティム

4

1 に答える 1

0

UIViewController を使用している可能性があるため、このコードを UITableViewController 内に配置する必要があるため、tableview への参照がないか、UITableView を UIViewController に追加して IBOutlet に接続できます。

于 2012-08-26T21:06:38.563 に答える