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