Mock Hard Drive Architecture

Sage
Posts: 1,066
Joined: 2004.07
Post: #1
If I wanted my game to generate a mock-hard drive architecture where the user can go through files and folders, should I use NSDictionary? It sounded good but once I started I wondered if that would be too much work for the task. Any suggestions? The idea is not to get the current computer's folders and files, but just so I can make a virtual computer with a folder set up. Thanks in advance and for all the previous (and future) help.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
sounds reasonable.
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #3
Ok. I used Property List Editor and got this file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>My Documents</key>
    <dict>
        <key>Files</key>
        <array>
            <string>file1.txt</string>
            <string>file2.txt</string>
            <string>file3.txt</string>
            <string>file4.txt</string>
        </array>
        <key>My Pictures</key>
        <dict>
            <key>Files</key>
            <array>
                <string>pic1.jpg</string>
                <string>pic2.jpg</string>
                <string>pic3.jpg</string>
                <string>pic4.jpg</string>
            </array>
            <key>Name</key>
            <string>My Pictures</string>
        </dict>
        <key>Name</key>
        <string>My Documents</string>
    </dict>
    <key>Name</key>
    <string>root</string>
</dict>
</plist>
But when I use initWithContentsOfFile:@"computer" (computer.plist is the file name) it returns nil. Did I forget something or am I just doing this wrong?
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #4
Nick Wrote:But when I use initWithContentsOfFile:@"computer" (computer.plist is the file name) it returns nil. Did I forget something or am I just doing this wrong?
I don't recall where initWithContentsOfFile searches from, but it's not the Resources directory. So in short: are you sure the path is right?
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #5
I've also put computer.plist in the build directory and it still didn't work.
Quote this message in a reply
Moderator
Posts: 771
Joined: 2003.04
Post: #6
This is some old code of mine, there is probably a better way...

initWithContentsOfFile:[[NSBundle bundleForClass:[self class]] pathForResource:@"computer" ofType:@"plist"]];
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #7
Thanks a bunch. That got it to work.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Level architecture question Jmcclane 4 4,027 Nov 27, 2011 01:52 PM
Last Post: Jmcclane
  Undefined symbols for architecture i386: "_SCNetworkReachabilitySetCallback" sefiroths 1 7,121 Aug 19, 2011 05:45 AM
Last Post: sefiroths
  Die-hard vertex-sorting function not accepting input values! mikey 6 3,865 Oct 31, 2009 03:36 AM
Last Post: mikey