ViewController1 に UITableView があります。選択すると、ViewController2 が読み込まれ、選択されたそれぞれの行の名前を持つ変数 (「passedData」として宣言されている)が保持されます。コードの実行可能性をテストする際に、ViewController2 のラベルに「passedData」を次のように割り当てました。
label.text = "passedData";
それはうまく機能します。ViewController1 のテーブルビューのリストには、サマリー、レポート、詳細などの一時的な命名規則で配列からロードされた行があります。
したがって、「Summary」を選択すると、ViewController2 がロードされ、それが SummaryViewController に関連する別のサブビューをロードします。ViewController2にサブロードするView Controllerを認識させようとして、私はこれを-(void) viewDidLoad:
NSString *viewtoload = passedData;
if (viewtoload == "Summary") {
//Load summaryViewController
}
elseif (viewtoload == "Report") {
//Load reportViewController
}
elseif (viewtoload == "Detail") {
//Load detailViewController
}
私はこのエラーを受け取りました:
1. Implicit conversion of a non-objective-C pointer type 'char *' to 'NSString *' is disallowed with ARC.
2. Result of comparison against a string literal is unspecified (use strncmp instead)
3. Comparison of distinct pointer types ('NSString *' and 'char *')
私の質問は次のとおりです。
1)これは正しいアプローチですか、それともより良い方法がありますか?
2) 上記のエラーを解決するにはどうすればよいですか?
3) 別のサブビューをロードする構文は?
よろしくお願いします。