Вот как выглядит plist в необработанном виде:
{
authorLastName = Doe;
authorFirstName = Jane;
imageFilePath = "NoImage.png";
title = "Account Test 1";
year = 2009;
},
{
authorLastName = Doe;
authorFirstName = John;
imageFilePath = "NoImage.png";
title = "Account Test 2";
year = 2009;
},
Я хочу подсчитать общее количество элементов списка и отобразить их следующим образом: «4 счета».
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *myPlistPath = [documentsDirectory
stringByAppendingPathComponent:@"Accounts.plist"];
NSDictionary *plistDict = [[NSDictionary alloc] initWithContentsOfFile:myPlistPath];
NSArray *array = [[plistDict objectForKey:0]
sortedArrayUsingSelector:@selector(compare:)];
return([NSString stringWithFormat:@"%d Accounts", [array count]]);
Однако результат возвращает 0. Я хочу, чтобы он возвращал количество элементов в словаре.