2011-08-16 10 views
0

明らかに、私はiOS開発の新人ですが、本当に誰かの助けを使うことができます。 .plistsをドリルダウンテーブルビューにロードしようとしているタブバーアプリケーションをビルドしています。問題は、ViewControllerのタブのナビゲーションコントローラを使用しようとしているので、このメソッドを正しく取得できないように見えることです。私の誤りは2番目の行にあると私は肯定的です。UIApplication sharedApplicationを使用するとエラーが発生しますか?

A37dgAppDelegate *AppDelegate = (A37dgAppDelegate *)[[UIApplication sharedApplication] delegate]; 
AppDelegate.indNavControl *indNavControl; 

その後、いくつかのエラーが発生します。ここでは、コードで、エラーがどこにあるか私は指摘します:

if([Children count] == 0) { 

    DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:[NSBundle mainBundle]]; 

    [self.indNavControl pushViewController:dvController animated:YES];//Property "indNavControl" not found on object of type "IndustriesViewController" 
    [dvController release]; 
} 
else { 

    //Prepare to tableview. 
    IndustriesViewController *indViewControl = [[IndustriesViewController alloc] initWithNibName:@"IndustryView" bundle:[NSBundle mainBundle]]; 

    //Increment the Current View 
    indViewControl.CurrentLevel += 1; 

    //Set the title; 
    indViewControl.CurrentTitle = [dictionary objectForKey:@"Title"]; 

    //Push the new table view on the stack 
    [self.indNavControl pushViewController:indViewControl animated:YES]; //Property "indNavControl" not found on object of type "IndustriesViewController" 

    indViewControl.tableDataSource = Children; 

    [indViewControl release]; 
} 

}

ただ、明確にするために、私は私のアプリデリゲートのヘッダファイルをインポートしています。任意の助けが大いに感謝されるでしょう:)

+0

私はあなたのコードを時間のクーペを読んだが、私はそれを理解していない。具体的には 'AppDelegate.indNavControl * indNavControl;' - それは合法ですか?それは何をしようとしていますか?第2に、エラーから、2番目のコードブロックがIndustriesViewControllerから来て、そのクラスにindNavControlプロパティがないように見えます。これら2つのコードセクションがどのように関連しているのか、なぜアプリケーションデリゲートを実行する必要があるのか​​分かりません。また、IndustriesNavController内からIndustriesNavControllerを割り当てようとしているようです。または私は何かを逃していますか? :-) – drekka

答えて

1

AppDelegate.indNavControl *indNavControl;が間違っています。私はあなたがこの行を全く必要としないと思う。また、新しいビューコントローラを押しながら、あなたは直接AppDelegate.indNavControl代わりのself.indNavControl、問題は2行目にあることを

[AppDelegate.indNavControl pushViewController:... 
+0

あなたは私を救った、ありがとう! –

+0

ようこそ!乾杯! – EmptyStack

0

あなたの理論が正しいことを使用することができます。

AppDelegate.indNavControl *indNavControl; 

この行は実際に何もしていません。 AppDelegate.indNavControlのクラスが必要です。

あなたはオプションのカップルがあります:あなたはindViewControlが

* in your IndustriesViewController.h, move the declaration of indViewControl there. 

@interface 
{ 
    WhateverClass *indNavControl; 
} 

@property (retain) WhateverClass*indNavControl; 
@end 

2「公共」プロパティになりたい場合は、私有財産をしたい場合は、その後で、空のカテゴリを追加)

1)上記のivarとプロパティの宣言を使用して、.mの上に移動します。

コンパイラが不満な点は、存在しないプロパティにアクセスしようとしていることです。

self.whateverIvarを呼び出す場合は、@propertyの定義が必要です。

0

のようにappdelegateのインスタンスを最初に作成してから、appdelegateで宣言した変数にアクセスして、プロパティとしてsynthesizeすることができます。indNavControlの別個の変数を作成する必要はありません。

関連する問題