Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I wrote an <a href="https://github.com/vikingosegundo/my-programming-examples/tree/master/MyContacts" rel="nofollow">example code</a>, that is an address book. It reads the data from a plist.</p> <p>the plist:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt; &lt;plist version="1.0"&gt; &lt;array&gt; &lt;dict&gt; &lt;key&gt;name&lt;/key&gt; &lt;string&gt;Vikingo&lt;/string&gt; &lt;key&gt;familyname&lt;/key&gt; &lt;string&gt;Segundo&lt;/string&gt; &lt;key&gt;street&lt;/key&gt; &lt;string&gt;Avenida Roca y Coranado&lt;/string&gt; &lt;key&gt;number&lt;/key&gt; &lt;integer&gt;20&lt;/integer&gt; &lt;key&gt;city&lt;/key&gt; &lt;string&gt;Santa Cruz de la Sierra&lt;/string&gt; &lt;key&gt;province&lt;/key&gt; &lt;string&gt;Santa Cruz&lt;/string&gt; &lt;key&gt;country&lt;/key&gt; &lt;string&gt;Bolivia&lt;/string&gt; &lt;key&gt;pictureurl&lt;/key&gt; &lt;string&gt;vikingosegundo.png&lt;/string&gt; &lt;/dict&gt; &lt;dict&gt; &lt;key&gt;name&lt;/key&gt; &lt;string&gt;Santa&lt;/string&gt; &lt;key&gt;familyname&lt;/key&gt; &lt;string&gt;Claus&lt;/string&gt; &lt;key&gt;street&lt;/key&gt; &lt;string&gt;Avenida Roca y Coranado&lt;/string&gt; &lt;key&gt;number&lt;/key&gt; &lt;integer&gt;20&lt;/integer&gt; &lt;key&gt;city&lt;/key&gt; &lt;string&gt;Santa Cruz de la Sierra&lt;/string&gt; &lt;key&gt;province&lt;/key&gt; &lt;string&gt;Santa Cruz&lt;/string&gt; &lt;key&gt;country&lt;/key&gt; &lt;string&gt;Finland&lt;/string&gt; &lt;key&gt;pictureurl&lt;/key&gt; &lt;string&gt;robot-santa.png&lt;/string&gt; &lt;/dict&gt; &lt;/array&gt; &lt;/plist&gt; </code></pre> <p>read the plist:</p> <pre><code>NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"contacts" ofType:@"plist"]; contacts = [[NSArray arrayWithContentsOfFile:plistPath] retain]; </code></pre> <p>display contacts in tableview:</p> <pre><code>- (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]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload