读取plist配置文件

配置文件如下:xml





	Student
	
		Name
		Yang
		Sex
		Male
		Num
		SX_010
	
	Mentor
	
		Name
		Gu
		Sex
		Male
	

读取方式:

//首先读取studentInfo.plist中的数据
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"customInfo" ofType:@"plist"];
NSDictionary *dictionary = [[NSDictionary alloc] initWithContentsOfFile:plistPath];
    
//将学生信息填入视图
NSDictionary *tmpInfo = [dictionary objectForKey: @"Student"];
self.stuName.text = [NSString stringWithFormat:@"%@", [tmpInfo objectForKey: @"Name"]];
self.stuSex.text = [NSString stringWithFormat:@"%@", [tmpInfo objectForKey: @"Sex"]];
self.stuNum.text = [NSString stringWithFormat:@"%@", [tmpInfo objectForKey: @"Num"]];

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(ios征程)