Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning iOS 4 Application Development
This is the forum to discuss the Wrox book Beginning iOS 4 Application Development by Wei-Meng Lee; ISBN: 978-0-470-91802-9
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning iOS 4 Application Development section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 2nd, 2012, 08:07 AM
Authorized User
Points: 92, Level: 1
Points: 92, Level: 1 Points: 92, Level: 1 Points: 92, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to FrankNatoli
Default Multi-dimensional plist

Chapter 8, Using the Table View, starts with a relatively simple plist. Although the book doesn't show the XML source of the plist, I believe the simple example is an array of "dict" objects.

But what about the more complex plist, page 213? First dimension is year, second dimension is movie titles. What would the XML source of this plist look like?

I'm guessing an outside array of "dict" objects, each object containing a single key/string pair for the year. Then inside each "dict" object is an "array" containing an inside array of "dict" objects, multiple in this case, all the movie titles.

Something like this:

Code:
<array>
  <dict>
    <key>year</key>
    <string>2000</string>
    <array>
      <dict>
        <key>title</key>
        <string>Malcolm X</sting>
      </dict>
      <dict>
        <key>title</key>
        <string>The Pelican Brief</string>
      </dict>
    </array>
  </dict>
  <dict>
    <key>year</key>
    <string>2001</string>
etc.

Is this correct?
Reply With Quote
  #2 (permalink)  
Old May 2nd, 2012, 12:10 PM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

Based on the download, the Movies.plist is a dictionary of arrays.


Code:
<?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">
<dict>
	<key>2000</key>
	<array>
		<string>Malcolm X</string>
		<string>The Pelican Brief</string>
		<string>The Hurricane</string>
	</array>
	<key>2001</key>
	<array>
		<string>Remember the Titans</string>
		<string>The Bone Collector</string>
	</array>
	<key>2002</key>
	<array>
		<string>John Q.</string>
	</array>
	<key>2004</key>
	<array>
		<string>Man on Fire</string>
		<string>Out of Time</string>
		<string>Training Day</string>
		<string>License to Kill</string>
		<string>Carbon Copy</string>
	</array>
	<key>2006</key>
	<array>
		<string>A Hand to Guide Me</string>
		<string>Inside Man</string>
	</array>
	<key>2007</key>
	<array>
		<string>Deja Vu </string>
	</array>
	<key>2008</key>
	<array>
		<string>The Great Debaters</string>
		<string>American Gangster</string>
	</array>
</dict>
</plist>
Since there is only one key (title in your example) a dictionary of dictionaries would not be needed.

To see a more complex .plist you might check out the PList project for Chapter 10 of the book at this link.
http://p2p.wrox.com/book-professiona...velopment-604/
Run the program, enter some contacts and then inspect the stored .plist
Bob

Last edited by thepianoguy; May 2nd, 2012 at 02:35 PM. Reason: grammer error
Reply With Quote
  #3 (permalink)  
Old May 2nd, 2012, 01:19 PM
Authorized User
Points: 92, Level: 1
Points: 92, Level: 1 Points: 92, Level: 1 Points: 92, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to FrankNatoli
Default Multi-dimensional plist

Great, exactly what I needed to know.

I'm actually implementing something a bit more complicated than the chapter demo, so I will have an inner array of dicts, but your plist shows that the outer dimension is effectively implemented by the list of [year] keys.

Thanks much.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search Bar with Plist and next View Jule BOOK: Beginning iPhone SDK Programming with Objective-C 1 February 24th, 2012 11:32 PM
could any one post xsl code to convert plist to xml using xsl andviceversa to plist venkat880 XSLT 0 August 4th, 2011 09:21 AM
Insertion in sorted multi-dimensional array. rupen Classic ASP Professional 1 October 31st, 2010 12:59 PM
push to multi dimensional harpua PHP How-To 0 December 4th, 2006 12:47 AM
resizeable multi-dimensional array 132591 C++ Programming 2 October 20th, 2006 05:07 PM



All times are GMT -4. The time now is 08:31 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.