无法从我的 Info.plist 文件中提取多个键数组

Cannot Fetch more than one key arrays from my Info.plist file

我正在尝试根据 Info.plist 中的两个键获取两个数组,但在我的输出中没有得到任何数据。这是我的代码。

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH,0),^{
        NSString *post = [NSString stringWithFormat:@"URL"];
        NSDictionary *dTmp = [[NSDictionary alloc] initWithContentsOfURL:[NSURL URLWithString:post]];
        NSMutableArray *OriginalDetailsArray=[dTmp valueForKey:@"Objects"];
        NSMutableArray *OriginalGalleryArray=[dTmp valueForKey:@"gallery"];
        detailsArray=[[NSMutableArray alloc] init];
        [detailsArray addObjectsFromArray:OriginalDetailsArray];
        galleryArray=[[NSMutableArray alloc] init];
        [galleryArray addObjectsFromArray:OriginalGalleryArray];

        dispatch_async(dispatch_get_main_queue(), ^{
            NSLog(@"%@, %@",detailsArray, galleryArray);
        });
    });

Out Put is: 您可以看到输出中没有任何内容,只有空括号。

 (
), (
)

这是我的 Info.plist 文件。如果我删除第二个数组 "Gallery" 并且我只让 "Objects" 数据完美获取。但在添加第二个数组后,它给出了空输出。

<plist version="1.0">
<dict>
<key>Objects</key>
<array>
<dict>
<key>propid</key>
<integer>233</integer>
<key>title</key>
<string>101 Perthshire Private</string>
<key>type</key>
<string>For Sale</string>
<key>price</key>
<string>9,900</string>
<key>bed</key>
<string>2</string>
<key>bath</key>
<string>3</string>
</dict>
</array>
</dict>

<dict>
<key>gallery</key>
<array>
<dict>
<key>imageurl</key>
<string>
/images/23330.jpg
</string>
</dict>
<dict>
<key>imageurl</key>
<string>
/images/23333.jpg
</string>
</dict>
<dict>
<key>imageurl</key>
<string>
/images/23339.jpg
</string>
</dict>
</array>
</dict>
</plist>

请尝试下面的代码,我得到了结果。

NSArray *arrayObjects = [NSArray arrayWithArray:[dictRoot objectForKey:@"Objects"]];

NSArray *arrayGallery = [NSArray arrayWithArray:[dictRoot objectForKey:@"gallery"]];

NSLog(@"%@",arrayObjects); 
NSLog(@"%@",arrayGallery);

你的plist数据格式有误。请将以下代码放入您的 php 文件并检查它。

<plist version="1.0">
    <dict>
        <key>Objects</key>
        <array>
            <dict>
                <key>propid</key>
                <integer>233</integer>
                <key>title</key>
                <string>101 Perthshire Private</string>
                <key>type</key>
                <string>For Sale</string>
                <key>price</key>
                <string>9,900</string>
                <key>bed</key>
                <string>2</string>
                <key>bath</key>
                <string>3</string>
            </dict>
        </array>
        <key>gallery</key>
        <array>
            <dict>
                <key>imageurl</key>
                <string>/images/23330.jpg</string>
            </dict>
            <dict>
                <key>imageurl</key>
                <string>/images/23333.jpg</string>
            </dict>
            <dict>
                <key>imageurl</key>
                <string>/images/23339.jpg
                </string>
            </dict>
        </array>
    </dict>
</plist>