2012-02-19 7 views
1

インターネットで多くの検索をした後、私のピッカーのビューにplistを入れても問題は残ります。私が間違っているのは何....Plistのアイテムを見ることができません

- (void)viewDidLoad 
NSString *path = [[NSBundle mainBundle] pathForResource:@"myPlist" ofType:@"plist"]; 
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path]; 
self.myPlist = dict; 


-(NSString *) pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component 
NSMutableArray *temp = [[NSMutableArray alloc] initWithArray:myPlist.allKeys]; 
return [temp objectAtIndex:row]; 

結果は単に "ルート" を示しています

<dict> 
<key>root</key> 
<dict> 
    <key>roof</key> 
    <array> 
     <string>80</string> 
     <string>100</string> 
    </array> 
</dict> 

私のコードは次のとおりです。これは私のplistのでしょうか?どんなアイデアでも大歓迎です。

答えて

0

データソースデリゲートを実装しましたか?

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView 

この参照:サイドノート、なぜあなたは可変配列の一時を作成しているとしても

When to use a plist, UIPickerView datasource help

を?あなたがARCを使用していない場合、必要ではなく、漏れているはずです。何か質問があれば教えてください。

+0

hello daltoniam、ご協力いただきありがとうございます。既に解決策があります。問題は、plistは元々辞書であり、配列ではないので、私の.hファイルではNSDictionary変数(NSDicionary * myplist)を使用し、次に私はNSDicitionaryでピッカービューメソッドを働かせました。 – Japa

関連する問題