我创建了一个属性列表,其中包含如下逻辑路径:
<array>
<dict>
<key>Title</key>
<string>Construction</string>
<key>Children</key>
<array>
<dict>
<key>Title</key>
<string>Advisory Services</string>
</dict>
<dict>
<key>Title</key>
<string>Disputes Services</string>
<key>Details</key>
<dict>
<key>Title</key>
<string>Disputes Services</string>
<key>Associated Image</key>
<string>Construction_iPhone.png</string>
<key>Industry Info</key>
<string>Planning and executing a construction project is a complex process that can be thrown off course by a variety of factors. Many root causes of delivery overrun are seeded during project development and procurement. Through our extensive construction dispute experience, we have discerned patterns of cost and schedule overruns and project failures that repeat themselves among projects. We leverage this insight to help owners, contractors, providers of capital and counsel identify and proactively manage potential problems throughout the lifecycle of large construction projects. We also help to manage the risks associated with any claims arising in those projects, particularly those in the infrastructure, healthcare and energy industries.</string>
</dict>
</dict>
</array>
我创建了一个向下钻取的应用程序,它实际上将您带到了字符串列表。我现在想要设置我的详细视图控制器,所以我创建了一些变量来让我开始。
//DetailViewController.h
IBOutlet NSString *title;
IBOutlet UIImage *associatedImage;
IBOutlet NSString *IndustryInfo;
我将一个图像和两个文本框拖到界面构建器中。相应地联系了他们。它只是页面顶部的图像,然后是两个文本框,没有太复杂。
显然,我想将其设置为只使用属性列表来获取此信息。问题是我是iOS开发的新手。如何在我的实现中使用objectForKey设置一个方法来解析我想要的信息并将其显示在屏幕上?另外,考虑到我将其设置为我的.plist中的字符串,我将如何设置UIImage?谢谢!
答案 0 :(得分:0)
您可以使用NSPropertyListSerialization或[NSArray arrayWithContentsOfFile:...]
或[NSDictionary dictionaryWithContentsOfFile:...]
阅读plist文件,具体取决于您的plist。我不确定您是如何设置图片的,但可以使用[UIImage imageNamed:...]
或[UIImage imageWithContentsOfFile:...]
加载图片。