cocos2d for iPhoneで、以下をforループにして値の範囲を指定できるようにする方法はありますか? 現時点では、単純にすべての値を通過します (ただし、正しい順序ではありません)。
// plist file
NSString * file = @"myproperties";
NSString * dictPath = [[NSBundle mainBundle] pathForResource:file
ofType:@"plist"];
// get dictionary
NSMutableDictionary * dictPlist = [[NSMutableDictionary alloc]
initWithContentsOfFile:dictPath];
NSEnumerator *enumerator = [dictPlist objectEnumerator ];
id value;
while ((value = [enumerator nextObject])) {
CCLog("Test: @%", [value objectForKey:@"Name"]);
}
10 から 15 の範囲のアイテムのみを印刷できるようにしたいと考えています (データがリストにある順序で)。それはどのように達成できますか?
編集: (順序を維持するために) dict の代わりに配列を使用する場合、次のリストをどのように変更する必要がありますか?
<?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>personTom</key>
<dict>
<key>Name</key>
<string>Tom</string>
<key>Age</key>
<integer>30</integer>
</dict>
<key>personJames</key>
<dict>
<key>Name</key>
<string>James</string>
<key>Age</key>
<integer>45</integer>
</dict>
<!-- (...) -->
</dict>
</plist>