Ios 如何获取此词典的值

Ios 如何获取此词典的值,ios,objective-c,nsarray,nsdictionary,Ios,Objective C,Nsarray,Nsdictionary,我有一个传入词典,如下所示: (此信息已更新) } 我已尝试将其转换为数组: NSArray*array=[dictionary allValues] 但是我在数组中得到一个项目,我想要三个。我该怎么做 更新:根据要求,这是我当前的代码剪报 - (void)awakeWithContext:(id)context { [super awakeWithContext:context]; if ([WCSession isSupported]) { NSLog(@"

我有一个传入词典,如下所示: (此信息已更新)

}

我已尝试将其转换为数组:

NSArray*array=[dictionary allValues]

但是我在数组中得到一个项目,我想要三个。我该怎么做

更新:根据要求,这是我当前的代码剪报

- (void)awakeWithContext:(id)context {

    [super awakeWithContext:context];
    if ([WCSession isSupported]) {
        NSLog(@"session isSupported...");
        self.session = [WCSession defaultSession];
        self.session.delegate = self;
        [self.session activateSession];

        NSError *error = nil;
        NSArray *directories = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documents = [directories firstObject];

        pathString = [documents stringByAppendingPathComponent:@"Favorites.plist"];
        NSLog(@"pathString > %@", pathString);

        NSFileManager *fileManager = [NSFileManager defaultManager];
        if (![fileManager fileExistsAtPath: pathString]) //4
        {
            NSString *bundle = [[NSBundle mainBundle] pathForResource:@"Favorites" ofType:@"plist"];

            [fileManager copyItemAtPath:bundle toPath: pathString error:&error];
        }

        if ([[NSFileManager defaultManager] fileExistsAtPath:pathString]) {
            [self readFromFile:pathString];
            NSMutableDictionary  *dictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:pathString];
            //NSLog(@" count: %lu", (unsigned long)dictionary.count);
            NSLog(@" dictionary: %@", dictionary);

            NSArray *tempArray = [dictionary allValues];
            self.workingArray = [tempArray mutableCopy];

            [self configureTable];
        }

    }
}

这三个值位于名为“StationFavorites.plist”的键下

因此,请尝试以下方法:

[(NSDictionary *)dictionary[@"StationFavourites.plist"] allValues];

这三个值位于名为“StationFavorites.plist”的键下

因此,请尝试以下方法:

[(NSDictionary *)dictionary[@"StationFavourites.plist"] allValues];

添加您的代码。也是你想要的结局。您拥有的是一本词典,其中有三个条目,分别名为“item1”、“item2”和“item3”,每个条目都是一本词典。您的词典列表不完整--您省略了开头和结尾的
{}
字符,它们对于理解它至关重要。@zaph-参见John Martin的答案——字典只包含一个条目。您因未包含代码、未包含所获得的结果以及未包含所有源数据而被否决。寻求调试帮助的问题(“此代码为什么不起作用?”)必须包括所需的行为、特定的问题或错误以及在问题本身中重现这些问题所需的最短代码。添加您的代码。也是你想要的结局。您拥有的是一本词典,其中有三个条目,分别名为“item1”、“item2”和“item3”,每个条目都是一本词典。您的词典列表不完整--您省略了开头和结尾的
{}
字符,它们对于理解它至关重要。@zaph-参见John Martin的答案——字典只包含一个条目。您因未包含代码、未包含所获得的结果以及未包含所有源数据而被否决。寻求调试帮助的问题(“此代码为什么不起作用?”)必须包括所需的行为、特定的问题或错误以及在问题本身中重现这些问题所需的最短代码。
[(NSDictionary *)dictionary[@"StationFavourites.plist"] allValues];