arkmon
arkmon

Reputation: 121

How to parse plist data in to UITableView using appropriate keys?

I am very new to Objective-C. Here is what I want. I have a tab view app for an iPhone. In one of the tabs I need to have table view with a data from the plist file. Data consist of text, pictures and location.

Upvotes: 0

Views: 200

Answers (2)

Damien Locque
Damien Locque

Reputation: 1809

You can try something like this :

SString *myFile = [[NSBundle mainBundle] pathForResource:@"plistName" ofType:@"plist"];
NSDictionary *dict = [[NSDictionary alloc]initWithContentsOfFile:myFile];

Upvotes: 1

Jakub
Jakub

Reputation: 13860

Plist file is in fact a xml file (you can open in in external editor and you should see the structure). So you should store data in NSDictionary (object and keys structure like xml file!).

For example:

    NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"plistFile" ofType:@"plist"];
    NSDictionary *dic = [[NSDictionary alloc] initWithContentsOfFile:plistPath];

I don't know if you have in plist file Arrays or Strings... you should provide some more information.

Upvotes: 1

Related Questions