0
基本上我需要得到一個隨機字母和與來自plist的那封信相關的點。當我得到這個工作,我會是 如何從嵌套在plist文件字典中的數組中訪問隨機值?
: 我真的不知道我有我的plist在儘可能最好的方式做到這一點成立,我從來沒有用的plist工作過將每個字母相關的點添加到plist中。我只是創建了一個基本的字平鋪遊戲來嘗試和學習sprite套件。
到目前爲止,我已經能夠訪問plist文件,但沒有得到任何運氣得到一個隨機的信,它是Points.I'm得到我嘗試的一切的各種錯誤。
Here's my code so far to access the plist:
NSString* fileName = @"letters.plist";
NSString* filepath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:fileName];
NSDictionary* lettersPlist = [NSDictionary dictionaryWithContentsOfFile:filepath];
NSDictionary* letters = lettersPlist[@"letters"];
那麼我怎樣才能得到一個隨機信,它是從這個plist點?有沒有更好的方法來做到這一點?
不錯!我只是做了你的建議,然後不得不改變字母指針到一個NSArray,並做了訣竅。 – Scott
@Scotty對不起,我甚至沒有看到它是你的示例代碼中的'Dictionary',因爲它是你的plist中的一個'Array';)對不起, –
沒有問題。由於我收到的錯誤非常明顯,我需要做的事情。 – Scott