Mock Hard Drive Architecture
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.
sounds reasonable.
Ok. I used Property List Editor and got this file:
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?
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>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?
I've also put computer.plist in the build directory and it still didn't work.
This is some old code of mine, there is probably a better way...
initWithContentsOfFile:[[NSBundle bundleForClass:[self class]] pathForResource:@"computer" ofType:@"plist"]];
initWithContentsOfFile:[[NSBundle bundleForClass:[self class]] pathForResource:@"computer" ofType:@"plist"]];
Thanks a bunch. That got it to work.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Level architecture question | Jmcclane | 4 | 3,471 |
Nov 27, 2011 01:52 PM Last Post: Jmcclane |
|
| Undefined symbols for architecture i386: "_SCNetworkReachabilitySetCallback" | sefiroths | 1 | 6,120 |
Aug 19, 2011 05:45 AM Last Post: sefiroths |
|
| Die-hard vertex-sorting function not accepting input values! | mikey | 6 | 3,245 |
Oct 31, 2009 03:36 AM Last Post: mikey |
|

