Crash:
- (void)viewDidLoad
{
[ super viewDidLoad ];
UITextField * textField = [ [ UITextField alloc ] init ];
textField.textColor = [ UIColor colorWithCIColor:[ CIColor colorWithString:@"0 0 0 1" ] ];
[ self.view addSubview:textField ];
}
Xcode console:
warning: could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available.
Don't crash:
- (void)viewDidLoad
{
[ super viewDidLoad ];
UITextField * textField = [ [ UITextField alloc ] init ];
textField.text = @"text";
textField.textColor = [ UIColor colorWithCIColor:[ CIColor colorWithString:@"0 0 0 1" ] ];
[ self.view addSubview:textField ];
}
in empty project and empty UIViewController. iOS 14.2 / iPhone XS / Xcode 12.2 (12B45b).
Also it crash after clear all existing text in UItextFiled.
I verified this crash in a test app. Turns out, it's an infinitely-self-recursing, stack-delving kind of crash (see stack trace).
It's crashing because of the way you're initializing your UIColor from a CIColor. This is highly unconventional. CIColor objects really are meant to be used in the context of CoreImage.
If you do textField.textColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1];
there is no crash.
All this being said, your code probably shouldn't be crashing, and it's likely a bug in the API. It might be worth filing a bug report.