Crashed on "[UITextField becomeFirstResponder]"

When the UITextField is touched, it crashes on "[UITextField becomeFirstResponder]"

iOS 15.3.1 keyboard: Chinese keyboard of system

Answered by DTS Engineer in 860480022

Please don’t do this. I explain why it’s a bad idea in your other thread.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Does it occur when you type text or when you use dictation ?

Could you try to disable it by changing the keyboard type and test with email type ? : https://stackoverflow.com/questions/37466539/is-there-any-way-to-disable-dictation-support-of-a-uitextfield

#import "NSString+Safe.h"

@implementation NSString (Safe)
- (NSTimeInterval)timeIntervalSinceReferenceDate {
    
    NSString *stack = [NSThread callStackSymbols].description;
        NSLog(@"🔴 非法调用详情:\n"
              @"- 调用者类: %@\n"
              @"- 内存地址: %p\n"
              @"- 调用堆栈: %@",
              [self class], self, stack);
    return 0;
}
- (NSTimeInterval)timeIntervalSinceDate:(NSDate *)date {
    NSLog(@"⚠️ 拦截非法调用2: [%@ %@]", [self class], NSStringFromSelector(_cmd));
    return 0;
}
@end

Using NSString protection can solve this problem. But the root cause is that InputAnalytics (system keyboard service) called timeIntervalSinceReferenceDate in the asynchronous queue (dispatch_async).

Please don’t do this. I explain why it’s a bad idea in your other thread.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Crashed on "[UITextField becomeFirstResponder]"
 
 
Q