I've encountered what I think is a bug in iOS16: When a localized string is passed from Swift to Objective-C and compared with another identical localized string (defined in Objective-CC), the result can be false and the parameter order can affect the result. See the demo:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let tc = TestClass()
tc.receive(NSLocalizedString("Start", comment:""))
}
}
@implementation TestClass
- (void)receive:(NSString *)swiftString {
NSString *objcString = NSLocalizedString(@"Start", @"");
BOOL result1 = [swiftString isEqualToString:objcString];
BOOL result2 = [objcString isEqualToString:swiftString];
NSLog(@"result: %d, %d", result1, result2);
}
@end
It is Localizable (take Japanese as one example, but any writing system other than Latin can reproduce the bug):
"Start" = "開始";
output:
result: 0, 1
We don't know whether the root cause of this is from NSLocalizedString()
or -isEqualToString
. This doesn't happen on iOS15.
Has anyone else encountered this bug?