鍦ㄤ唬鐮佸疄鐜癓able 銆乼extField鍒涘缓鐣岄潰浠ュ強閿?洏鐨勫?鐞嗕竴鏂囦腑瀹炵幇浠g爜甯冨眬鐣岄潰锛屽墠闈?篃鐪嬩簡plist鏂囦欢鐨勪竴浜涙搷浣滐紝鎬庢牱鎶妏list鏂囦欢涓?殑鍊兼樉绀哄湪瑙嗗浘涓婂憿锛屼簬鏄?湪浠g爜瀹炵幇Lable 銆乼extField鍒涘缓鐣岄潰浠ュ強閿?洏鐨勫?鐞嗕竴鏂囧伐绋嬩唬鐮佷腑娣诲姞浜嗗嚑琛屼唬鐮侊紝璁﹑list鏂囦欢涓?殑value鏄剧ず鍦╰extField涓?紱
1.鎵撳紑宸ョ▼涔嬪悗锛孎ile --> New -->File 鍦ㄥ脊鍑虹晫闈?腑宸︽爮閫変腑Mac os X 涓嬬殑Resourse涓?鏍忥紝閫変腑Property List锛岀偣鍑籒ext鍛藉悕涓簍estInfo.plist锛岀劧鍚庢墦寮?testInfo.plist鏂囦欢锛屽湪鏂囦欢涓婂彸閿瓵dd Row锛屾坊鍔犲?涓嬪ご鎵?绀烘暟鎹?鎴戠敤鐨刋code鐗堟湰鏄?.3.1锛岃?佺増鏈?殑鍙?兘鏈夌殑涓嶄竴鏍?
[img]
[/img]
鍦╒iew鐨勬渶鍚庨潰娣诲姞浠g爜
// 璇诲彇plist鏂囦欢 NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"testInfo" ofType:@"plist"]; NSMutableDictionary *data=[[NSMutableDictionary alloc] initWithContentsOfFile:plistPath]; // 鎵撳嵃鍑簆list鏂囦欢 NSLog(@"%@",data); //璇诲彇瀛︾敓瀛楀吀鐨勫唴瀹瑰埌StudentInfo涓璹u 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"]; //鍦╰eacher瀛楀吀涓?紝鎶婇敭涓篘ame鐨勫?艰祴缁檛NameTextField鐨則ext涓? tNameTextField.text = [NSString stringWithFormat:@"%@",[teacherInfo objectForKey:@"Name"]]; tSexTextField.text = [NSString stringWithFormat:@"%@",[teacherInfo objectForKey:@"Sex"]];
淇濆瓨杩愯?锛?
[img]
[/img]