Read from plist insted of Code array
Posted
by BoSoud
on Stack Overflow
See other posts from Stack Overflow
or by BoSoud
Published on 2010-06-12T21:09:09Z
Indexed on
2010/06/12
21:12 UTC
Read the original article
Hit count: 216
Hi Guys
am Using [URL="http://www.iphonesdkarticles.com/2009/01/uitableview-searching-table-view.html"]UITableView - Searching table view[/URL]
its really nice easy tutorial but i really have bad time try to read from plist
that what i did change
- (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;
}
and This How i read plist from My AppDelegate.m
- (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];
}
and this my plist
<plist version="1.0">
<dict>
<key>Countries</key>
<array>
<array>
<string>USA</string>
</array>
<dict/>
</array>
</dict>
</plist>
and i get this error
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFArray objectForKey:]: unrecognized selector sent to instance 0x1809dc0'
help please am stock with this
© Stack Overflow or respective owner