4つの別の配列を含む単一の配列を含むplistファイルを作成しました。各配列には4つの辞書が含まれています。plistファイルからデータを読み取ろうとたくさん試みました。しかし、データを取得できません。私のplistファイルのコードはここにあります
<plist version="1.0">
<dict>
<key>Root</key>
<array>
<array>
<dict>
<key>name</key>
<string>Czech Republic</string>
<key>imagename</key>
<string>czechrepublic.png</string>
<key>url</key>
<string>www.google.com</string>
</dict>
<dict>
<key>name</key>
<string>Greece</string>
<key>imagename</key>
<string>greece.png</string>
<key>url</key>
<string>www.google.com</string>
</dict>
<dict>
<key>name</key>
<string>Poland</string>
<key>imagename</key>
<string>poland.png</string>
<key>url</key>
<string>www.google.com</string>
</dict>
<dict>
<key>name</key>
<string>Russia</string>
<key>imagename</key>
<string>russia.png</string>
<key>url</key>
<string>www.google.com</string>
</dict>
</array>
<array>
<dict>
<key>name</key>
<string>Denmark</string>
<key>imagename</key>
<string>denmark.png</string>
<key>url</key>
<string>www.google.com</string>
</dict>
<dict>
<key>name</key>
<string>Germany</string>
<key>imagename</key>
<string>germany.png</string>
<key>url</key>
<string>www.google.com</string>
</dict>
<dict>
<key>name</key>
<string>Netherlands</string>
<key>imagename</key>
<string>netherlands.png</string>
<key>url</key>
<string>www.google.com</string>
</dict>
<dict>
<key>name</key>
<string>Portugal</string>
<key>imagename</key>
<string>portugal.png</string>
<key>url</key>
<string>www.google.com</string>
</dict>
</array>
<array>
<dict>
<key>name</key>
<string>Croatia</string>
<key>imagename</key>
<string>croatia.png</string>
<key>url</key>
<string>www.google.com</string>
</dict>
<dict>
<key>name</key>
<string>Italy</string>
<key>imagename</key>
<string>italy.png</string>
<key>url</key>
<string>www.google.com</string>
</dict>
<dict>
<key>name</key>
<string>Republic of Ireland</string>
<key>imagename</key>
<string>ireland.png</string>
<key>url</key>
<string>www.google.com</string>
</dict>
<dict>
<key>name</key>
<string>Spain</string>
<key>imagename</key>
<string>spain.png</string>
<key>url</key>
<string>www.google.com</string>
</dict>
</array>
<array>
<dict>
<key>name</key>
<string>England</string>
<key>imagename</key>
<string>england.png</string>
<key>url</key>
<string>www.google.com</string>
</dict>
<dict>
<key>name</key>
<string>France</string>
<key>imagename</key>
<string>france.png</string>
<key>url</key>
<string>www.google.com</string>
</dict>
<dict>
<key>name</key>
<string>Sweden</string>
<key>imagename</key>
<string>sweden.png</string>
<key>url</key>
<string>www.google.com</string>
</dict>
<dict>
<key>name</key>
<string>Ukraine</string>
<key>imagename</key>
<string>ukraine.png</string>
<key>url</key>
<string>www.google.com</string>
</dict>
</array>
</array>
</dict>
</plist>
このplistから読み取るために使用されるコードは
NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
// get documents path
NSString *documentsPath = [paths objectAtIndex:0];
// get the path to our Data/plist file
NSString *plistPath = [documentsPath stringByAppendingPathComponent:@"Data.plist"];
// check to see if Data.plist exists in documents
if (![[NSFileManager defaultManager] fileExistsAtPath:plistPath])
{
// if not in documents, get property list from main bundle
plistPath = [[NSBundle mainBundle] pathForResource:@"Data" ofType:@"plist"];
}
NSMutableDictionary *dict = [NSMutableDictionary alloc] initWithContentsOfFile:plistPath;
NSMutableArray *array = [dict objectForKey:@"Root"];
配列は空です。