如何在UItableview上显示嵌套的plist数据

时间:2014-02-25 03:21:56

标签: ios nsdictionary plist uitableview

我的plist文件如下所示:

<dict>
    <key>subject 1</key>
    <dict>
        <key>chapter 1</key>
        <array>
                   item 1
                   item 2
                     .
                     .
        </array>
        <key>chapter 2</key>
                 .
                 .
    </dict>
    <key>subject 2</key>

             .
             .

我怎样才能展示主题&amp;章节有关手风琴风格table-view的信息,并在detail-view

中显示这些项目

1 个答案:

答案 0 :(得分:0)

尝试此解决方案,如果您有任何疑问,请告诉我。

 -(NSArray *)Data
    {
        plistPath = [[NSBundle mainBundle] pathForResource:@"PlistName" ofType:@"plist"];
        NSMutableDictionary * propertyDict = [[NSMutableDictionary alloc] initWithContentsOfFile:plistPath];



       NSMutableDictionary *Key = [propertyDict objectForKey:@"subject 1"];

        NSArray *Chapter =(NSArray *) [Key objectForKey:@"chapter 1"];

        return Chapter;
    }