的我使用UITableView - Searching table view從plist中讀取insted的代碼陣列
其非常好的易教程,但我真的有不好的時候儘量從plist中讀取
什麼我沒有改變
- (void)viewDidLoad {
[super viewDidLoad];
//Initialize the array.
listOfItems = [[NSMutableArray alloc] init];
TableViewAppDelegate *AppDelegate = (TableViewAppDelegate *)[[UIApplication sharedApplication] delegate];
listOfItems = [AppDelegate.data objectForKey:@"Countries"];
//Initialize the copy array.
copyListOfItems = [[NSMutableArray alloc] init];
//Set the title
self.navigationItem.title = @"Countries";
//Add the search bar
self.tableView.tableHeaderView = searchBar;
searchBar.autocorrectionType = UITextAutocorrectionTypeNo;
searching = NO;
letUserSelectRow = YES;
}
這個我如何讀取我的AppDelegate.m的plist
- (void)applicationDidFinishLaunching:(UIApplication *)application {
NSString *Path = [[NSBundle mainBundle] bundlePath];
NSString *DataPath = [Path stringByAppendingPathComponent:@"Data.plist"];
NSDictionary *tempDict = [[NSDictionary alloc] initWithContentsOfFile:DataPath];
self.data = tempDict;
[tempDict release];
// Configure and show the window
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
}
,這我的plist
<plist version="1.0">
<dict>
<key>Countries</key>
<array>
<array>
<string>USA</string>
</array>
<array>
<string>UK</string>
</array>
</array>
</dict>
</plist>
和我得到這個錯誤
*終止應用程序由於未捕獲的異常 'NSInvalidArgumentException',原因是:「* - [NSCFArray objectForKey :]:無法識別的選擇器發送到實例0xe09120'
請幫助我的股票與此
在你的plist中,項目後的 項目是做什麼的? –
gnasher
2010-06-12 21:18:11
不能運行plist沒有 –
BoSoud
2010-06-13 15:33:42