1
在互聯網上進行了很多搜索之後,我仍然遇到了將我的plist放在我的選擇器視圖中的問題。這是我的plist:不能在Plist中看到項目
<dict>
<key>root</key>
<dict>
<key>roof</key>
<array>
<string>80</string>
<string>100</string>
</array>
</dict>
我的代碼是:
- (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];
結果只是顯示 「根」 ......我到底做錯了什麼?任何想法將不勝感激。
hello daltoniam,感謝您的幫助..我已經有了解決方案。問題是,plist最初是一個字典,而不是一個數組,所以在我的.h文件中,我使用了一個NSDictionary變量(NSDicionary * myplist),然後在我的.m上使用NSDicitionary工作了我的選擇器視圖方法。 – Japa 2012-03-18 23:29:29