Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3433740
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:36:47+00:00 2026-05-18T07:36:47+00:00

I’m using the example on page 210 of Beginning iPhone Development (Exploring the iPhone

  • 0

I’m using the example on page 210 of Beginning iPhone Development (Exploring the iPhone SDK) book and it’s similar to what I want to do but that specific example is complicated by using sections in the TableView. I have a specific hierarchy in my plist…

Root  ---- Dictionary
        Rows  ---- Array
                Item 0- Dictionary
                        fullName  ---- String
                        address   ---- String
                Item 1   ---- Dictionary
                        fullName  ---- String
                        address   ---- String

So I have a UITableView that takes up a small portion of the view on that “screen” The rest of the view has other elements so I chose nut to use a navigation template.

The code I’m using doesn’t match up because I’m really not clear on calling which fields.

Can someone show me a VERY simple example how I could list all the “firstNames” in that table. If something is wrong with my plist please let me know specifically what to change.

In a nutshell I want to loop through all the Item # dictionaries to list all the first names. My design is similar to a contact list, but not exactly a contact list.

Right now I’m using this code which simply displays the word “Rows” I changed the word rows to Rows1 in my plist and that shows up so it’s grabbing that “array item”. I hope I said that right.

-(void)viewDidLoad {    
    NSString *path = [[NSBundle mainBundle] pathForResource:@"data" ofType:@"plist"];

    NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
    self.names = dict;
    [dict release];

    NSArray *array = [[names allKeys] sortedArrayUsingSelector:@selector(compare:)];
    self.listData = array;

    [super viewDidLoad];
}

 

-(NSInteger)tableView:(UITableView *)tableView
 numberOfRowsInSection:(NSInteger)section {
    return [self.listData count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *SimpleTableIdentifier = @"Identifier";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier] autorelease];
    }

    NSUInteger row = [indexPath row];
    cell.textLabel.text = [listData objectAtIndex:row];
    return cell;
}

I’ve scoured the web for days trying to find a simple example that uses a plist hierarchy to list items in a table that is not part of a navigation template.

Thanks So Much

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T07:36:48+00:00Added an answer on May 18, 2026 at 7:36 am

    I wrote an example code, that is an address book. It reads the data from a plist.

    the plist:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <array>
        <dict>
            <key>name</key>
            <string>Vikingo</string>
            <key>familyname</key>
            <string>Segundo</string>
            <key>street</key>
            <string>Avenida Roca y Coranado</string>
            <key>number</key>
            <integer>20</integer>
            <key>city</key>
            <string>Santa Cruz de la Sierra</string>
            <key>province</key>
            <string>Santa Cruz</string>
            <key>country</key>
            <string>Bolivia</string>
            <key>pictureurl</key>
            <string>vikingosegundo.png</string>
        </dict>
        <dict>
            <key>name</key>
            <string>Santa</string>
            <key>familyname</key>
            <string>Claus</string>
            <key>street</key>
            <string>Avenida Roca y Coranado</string>
            <key>number</key>
            <integer>20</integer>
            <key>city</key>
            <string>Santa Cruz de la Sierra</string>
            <key>province</key>
            <string>Santa Cruz</string>
            <key>country</key>
            <string>Finland</string>
            <key>pictureurl</key>
            <string>robot-santa.png</string>
        </dict>
    </array>
    </plist>
    

    read the plist:

    NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"contacts" ofType:@"plist"];
    contacts = [[NSArray arrayWithContentsOfFile:plistPath] retain];
    

    display contacts in tableview:

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
        return 1;
    }
    
    
    // Customize the number of rows in the table view.
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        return [contacts count];
    }
    
    
    // Customize the appearance of table view cells.
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
        static NSString *CellIdentifier = @"Cell";
    
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        }
    
        NSDictionary *dict = [contacts objectAtIndex:indexPath.row];
        cell.textLabel.text = [NSString stringWithFormat:@"%@ %@", [dict objectForKey:@"name"], [dict objectForKey:@"familyname"]];
    
        return cell;
    }
    
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
        DetailContactViewController *detailViewController = [[DetailContactViewController alloc] initWithNibName:@"DetailContactView" bundle:nil];
        detailViewController.contact = [contacts objectAtIndex:indexPath.row];
        // ...
        // Pass the selected object to the new view controller.
        [self.navigationController pushViewController:detailViewController animated:YES];
    
        [detailViewController release];
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.