*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x115fadbc0'
*** First throw call stack:
(0x1940bd8c8 0x1910097c4 0x194159838 0x19403a4f8 0x1940423a0 0x1e42cb9a8 0x1e42ce220 0x106f02c08 0x1080a461c 0x1080be2b0 0x1080acb2c 0x1080ad7b4 0x1080b9b00 0x1080b91a4 0x1eecdb3b8 0x1eecda8c0)
libc++abi: terminating due to uncaught exception of type NSException
InputAnalytics called timeIntervalSinceReferenceDate in dispatch_sync.The display issue of the call stack occurs in two stages: keyboard input analysis and folding the keyboard.After adding protection to NSString, it can function normally, but I want to know the reason.
#import "NSString+Safe.h"
@implementation NSString (Safe)
- (NSTimeInterval)timeIntervalSinceReferenceDate {
return 0;
}
- (NSTimeInterval)timeIntervalSinceDate:(NSDate *)date {
return 0;
}
@end
Please please please don’t do this.
The crash you’re seeing is caused by a memory management problem. The most common cause of such problems is an over-release bug. That is, some code has over-released an NSDate
object, that same memory has been re-used as an NSString
object, and then some other code has using the original object pointer thinking it’s date when it’s now actually a string, and hence this exception.
You’re ‘fixing’ the crash by using an Objective-C category to add date methods to string objects, and string objects have no business having those methods. This is the wrong approach. Rather, you need to find the underlying memory management bug and resolve that.
My advice is that your run your app under the standard memory debugging tools. Specifically, Zombies is the tool of choice when debugging over-release problems.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"