gpt4 book ai didi

iphone - 获取 NSDictionary 的字符串

转载 作者:行者123 更新时间:2023-12-03 21:08:27 24 4
gpt4 key购买 nike

我有一个具有以下结构的plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>height</key>
<real>2075</real>
<key>name</key>
<string>Dublin-Pony-kids-25_thumb</string>
<key>width</key>
<real>1558</real>
</dict>
<dict>
<key>height</key>
<real>2219</real>
<key>name</key>
<string>Dublin-Pony-kids-26_thumb</string>
<key>width</key>
<real>1751</real>
</dict>
<dict>
<key>height</key>
<real>2532</real>
<key>name</key>
<string>Dublin-Pony-kids-27_thumb</string>
<key>width</key>
<real>1732</real>
</dict>
<dict>
<key>height</key>
<real>2430</real>
<key>name</key>
<string>Dublin-Pony-kids-28_thumb</string>
<key>width</key>
<real>1730</real>
</dict>
</array>
</plist>

我想知道如何获取包含 key->name 的所有结果的 NSString。我想要像 Dublin-Pony-kids-25_thumb、Dublin-Pony-kids-26_thumb、Dublin-Pony-kids-27_thumb、Dublin-Pony-kids-28_thumb 这样的东西。

我可以像 (NSString *)imageNameAtIndex:(NSUInteger)index { 那样读取它但这只返回一个值。我希望 key->name 的所有值都为 NSString

我对此很陌生,所以请帮忙。

最佳答案

如果将 plist 加载到数组中(通过 +[NSArray arrayWithContentsOfFile:...]),那么您应该能够执行以下操作:

NSArray *plistContents = [NSArray arrayWithContentsOfFile:...]; //load the plist into memory
NSArray *names = [plistContents valueForKey:@"name"];

关于iphone - 获取 NSDictionary 的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4891969/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com