I have a sample database file called albums.plist It is structured as below (very simple layout).
I am new to Objective-C programming and would learn a lot if someone is able to help me figure this out.
What I would like to do programatically is parse this database and for example, show on screen for example, the second albums details - that is album and artist - on two UILabels
One would be a UILabel called artist_name
and would therefore be set to: @"David Bowie"
and underneath another UILabel
called album_name
set to: @"Heroes"
Can someone help me out with this? I would learn a lot from it.
<?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>The Beatles</key>
<string>Let It Be</string>
<key>David Bowie</key>
<string>Heroes</string>
<key>Dire Straits</key>
<string>Brothers In Arms</string>
</dict>
</plist>
I have came across code below which I could probably use to open access to the file.
I just need a few pointers as to how to access the second record in the database?
Many Thanks.
NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *finalPath = [path stringByAppendingPathComponent:@"albums.plist"];
plistDictionary = [[NSDictionary dictionaryWithContentsOfFile:finalPath] retain];