在代码实现Lable 、textField创建界面以及键盘的处理一文中实现代码布局界面,前面也看了plist文件的一些操作,怎样把plist文件中的值显示在视图上呢,于是在代码实现Lable 、textField创建界面以及键盘的处理一文工程代码中添加了几行代码,让plist文件中的value显示在textField中;
1.打开工程之后,File --> New -->File 在弹出界面中左栏选中Mac os X 下的Resourse一栏,选中Property List,点击Next命名为testInfo.plist,然后打开testInfo.plist文件,在文件上右键Add Row,添加如下头所示数据(我用的Xcode版本是4.3.1,老版本的可能有的不一样)
[img]
[/img]
在View的最后面添加代码
// 读取plist文件
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"testInfo" ofType:@"plist"];
NSMutableDictionary *data=[[NSMutableDictionary alloc] initWithContentsOfFile:plistPath];
// 打印出plist文件
NSLog(@"%@",data);
//读取学生字典的内容到StudentInfo中qu
NSMutableDictionary *StudentInfo = [data objectForKey:@"Student"];
sNameTextField.text = [NSString stringWithFormat:@"%@",[StudentInfo objectForKey:@"Name"]];
sAgeTextField.text = [NSString stringWithFormat:@"%@",[StudentInfo objectForKey:@"Age"]];
sSexTextField.text = [NSString stringWithFormat:@"%@",[StudentInfo objectForKey:@"Sex"]];
NSMutableDictionary *teacherInfo = [data objectForKey:@"teacher"];
//在teacher字典中,把键为Name的值赋给tNameTextField的text上
tNameTextField.text = [NSString stringWithFormat:@"%@",[teacherInfo objectForKey:@"Name"]];
tSexTextField.text = [NSString stringWithFormat:@"%@",[teacherInfo objectForKey:@"Sex"]];
保存运行:
[img]
[/img]
- 大小: 121.1 KB
- 大小: 100.8 KB
分享到:
相关推荐
plist Editor-v2.5.0.1.exe
Info.plist
plist分解工具制作包 亲测有效.rar plist分解工具制作包 亲测有效.rar plist分解工具制作包 亲测有效.rar
org.chameleon.Boot.plist IntelHD4000已经驱动好了的文件
plistEditor修改INFO文件的工具
NBOrganizers.plist
configplist文件编辑器,可以自由编辑,分享给需要的人,黑苹果必备
全国省市区数据plist格式, 市级邮政编码。
使用java获取ipa包中info.plist,详见http://blog.csdn.net/akwolf/article/details/7197311
第三方jar包解析苹果应用IPA包中的Info.plist信息
城市Plist文件城市Plist文件城市Plist文件城市Plist文件城市Plist文件城市Plist文件城市Plist文件城市Plist文件城市Plist文件城市Plist文件城市Plist文件城市Plist文件城市Plist文件城市Plist文件城市Plist文件
详细注射 config.plist,不能直接导入使用,请根据个人电脑配置修改。
把脚本unpack_plist_2.py和图集文件xx_1.png、xx_1.plist、xx_2.png、xx_2.plist....放入同一个文件夹(可放多套图集),然后执行脚本,拆解后的小图在该文件夹下生成xx_1、xx_2...等对应的文件夹中
NSArray *ary = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ProvinceCityDistrict" ofType:@"plist"]]; for (int i = 0; i < ary.count; i ++) { NSDictionary *province = ary...
逆向还原 plist png 图片资源....................................................................................................................
ios在解锁或者备份shsh文件时,从手机里获取的plist文件是打不开的,我们可以通过java转成xml或者可以打的plist。shsh文件备份, import java.io.*; import com.dd.plist.PropertyListParser; public class ...
自己手写的小工具,所以...1.支持.atlas和.plist后缀 2.支持单个文件,也支持文件夹 3.有用户界面,也支持命令行 4.可执行的.jar文件已经export到资源里了,不需要自己手动操作一次 5.如果有bug,请各位同胞自行解决吧
调用jar把IOS的plist文件转成标准xml.