This repository was archived by the owner on Mar 21, 2025. It is now read-only.
File tree 2 files changed +24
-17
lines changed
2 files changed +24
-17
lines changed Original file line number Diff line number Diff line change @@ -601,11 +601,11 @@ - (void)loadCityData {
601
601
@" 659006" :@" 铁门关" ,
602
602
@" 659007" :@" 双河" ,
603
603
@" 659008" :@" 可克达拉" ,
604
- @" 710000" :@" 台湾 " ,
605
- @" 710100" :@" 台湾 " ,
606
- @" 810000" :@" 香港 " ,
607
- @" 810100" :@" 香港 " ,
608
- @" 820100" :@" 澳门 "
604
+ @" 710000" :@" 中国台湾 " ,
605
+ @" 710100" :@" 中国台湾 " ,
606
+ @" 810000" :@" 中国香港 " ,
607
+ @" 810100" :@" 中国香港 " ,
608
+ @" 820100" :@" 中国澳门 "
609
609
};
610
610
}
611
611
@@ -616,9 +616,7 @@ - (NSString *)getCityNameWithCode:(NSString *)code {
616
616
617
617
NSString *cityName = self.cityCodeMap [code];
618
618
619
- if (!cityName) {
620
619
return cityName;
621
- }
622
620
}
623
621
624
622
- (NSString *)getProvinceNameWithCode : (NSString *)code {
@@ -629,9 +627,7 @@ - (NSString *)getProvinceNameWithCode:(NSString *)code {
629
627
provinceCode = [provinceCode stringByAppendingString: @" 0000" ];
630
628
NSString *provinceCodeName = self.cityCodeMap [provinceCode];
631
629
632
- if (!provinceCodeName) {
633
- return provinceCodeName;
634
- }
630
+ return provinceCodeName;
635
631
}
636
632
637
633
@end
Original file line number Diff line number Diff line change 1099
1099
1100
1100
if (cityName.length > 0 && ![text containsString: cityName]) {
1101
1101
if (!self.model .ipAttribution ) {
1102
- if ([provinceName isEqualToString: cityName]) {
1102
+ BOOL isDirectCity = [provinceName isEqualToString: cityName] ||
1103
+ ([cityCode hasPrefix: @" 11" ] || [cityCode hasPrefix: @" 12" ] ||
1104
+ [cityCode hasPrefix: @" 31" ] || [cityCode hasPrefix: @" 50" ]);
1105
+
1106
+ if (isDirectCity) {
1103
1107
label.text = [NSString stringWithFormat: @" %@ IP属地:%@ " , text, cityName];
1104
1108
} else {
1105
1109
label.text = [NSString stringWithFormat: @" %@ IP属地:%@ %@ " , text, provinceName, cityName];
1106
1110
}
1107
1111
} else {
1108
- // 添加条件判断
1109
- if (![text isEqualToString: provinceName] || [cityName isEqualToString: text]) {
1110
- label.text = text;
1111
- } else {
1112
- label.text = [NSString stringWithFormat: @" %@ %@ " , text, cityName];
1113
- }
1112
+ BOOL isDirectCity = [provinceName isEqualToString: cityName] ||
1113
+ ([cityCode hasPrefix: @" 11" ] || [cityCode hasPrefix: @" 12" ] ||
1114
+ [cityCode hasPrefix: @" 31" ] || [cityCode hasPrefix: @" 50" ]);
1115
+
1116
+ BOOL containsProvince = [text containsString: provinceName];
1117
+
1118
+ if (isDirectCity && containsProvince) {
1119
+ label.text = text;
1120
+ } else if (containsProvince) {
1121
+ label.text = [NSString stringWithFormat: @" %@ %@ " , text, cityName];
1122
+ } else {
1123
+ label.text = text;
1124
+ }
1114
1125
}
1115
1126
}
1116
1127
}
You can’t perform that action at this time.
0 commit comments