File io 从plist问题生成数组

File io 从plist问题生成数组,file-io,nsarray,plist,ios5,File Io,Nsarray,Plist,Ios5,首先,一点背景。我想做一个平台游戏。在游戏层的前面,我想让“灯光”经过,我指的是白色三角形。我正试图从plist中获取三角形的坐标 在这一点上,我花了好几天的时间试图让我的应用程序从plist读取,但我无法让它工作。 这就是我目前所拥有的,这基本上就是互联网所说的我应该拥有的,它应该有效 在helloWorld.h中: NSMutableArray *foregroundLights; 在helloWorld.m NSString *path = [[NSBundle mainBundle]

首先,一点背景。我想做一个平台游戏。在游戏层的前面,我想让“灯光”经过,我指的是白色三角形。我正试图从plist中获取三角形的坐标

在这一点上,我花了好几天的时间试图让我的应用程序从plist读取,但我无法让它工作。 这就是我目前所拥有的,这基本上就是互联网所说的我应该拥有的,它应该有效

在helloWorld.h中:

NSMutableArray *foregroundLights;
在helloWorld.m

NSString *path = [[NSBundle mainBundle] pathForResource:@"foregroundlights" ofType:@"plist"];
foregroundLights = [[NSMutableArray alloc] initWithContentsOfFile:path];
我尝试了各种我能想到的格式化补丁的方法,我尝试了使用NSSearchPaths for Directory Indomains。我试着把plist做成一本字典,把它做成一个数组。我错过了什么

这是一张拼图。完整的一个包含50个4整数数组

<?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>root</key>
<array>
    <array>
        <integer>128</integer>
        <integer>68</integer>
        <integer>246</integer>
        <integer>7</integer>
    </array>
    <array>
        <integer>181</integer>
        <integer>84</integer>
        <integer>170</integer>
        <integer>62</integer>
    </array>
    <array>
        <integer>118</integer>
        <integer>51</integer>
        <integer>142</integer>
        <integer>64</integer>
    </array>
</array>
</dict>
</plist>

根
128
68
246
7.
181
84
170
62
118
51
142
64

现在plist是一个带有一个键“root”的字典,因此NSMutableArray init将返回nil。您是否尝试过删除
节点,并在plist中仅包含
?当你运行代码时,它是否给出了一个错误,或者数组是否为零?删除
到目前为止还有效,我还需要解决其他错误。奇怪的是,Xcode将初始字典添加到plist中。