Post

Replies

Boosts

Views

Activity

Comment on [Swift] How to properly subclass UITextfield and work with its delegate
@Claude31 I fixed the init() stuff, it's working now. It wasn't working before because I had the ViewController code which uses MyTextField to also have a UITextFieldDelegate: class ViewController: UIViewController, UITextFieldDelegate { override func viewDidLoad() { let myTF = MyTextField( .... ) myTF.delegate = self }    func textFieldDidBeginEditing(_ textField: UITextField) {     print("XXXXX"). // This is printed instead of "Inside subclassed textfield" within the subclass.   }  ``` So, if the subclassed textfield's delegate is set to self within the calling code (ViewController in this case), the textFieldDidBeginEditing() inside the subclass is never called. In general, is there a way to trigger textFieldDidBeginEditing() in both the calling code as well as the one inside the subclass?
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Comment on Color Literal behaves inconsistently in Xcode 13.2.1
That works, but it is still not possible to insert a color literal as an argument in a function. Example: setGradientBackground(topColor: QQQ, bottomColor: YYY) You can't put a color literal in place of QQQ and YYY. It forces it to: setGradientBackground(topColor: colorLiteral(red: 0.4745098054, green: 0.8392156959, blue: 0.9764705896, alpha: 1), bottomColor: colorLiteral(red: 0.5546397567, green: 0.3071874082, blue: 0.007406672928, alpha: 1))
Dec ’21
Comment on In the Platforms window, difference between iOS and iOS Simulator
OK, good to know. But the fact that there was an error during "Verifying iOS 17.2 simruntime" and yet iOS 17.2 appears in the Platforms list is a bit puzzling. Yes, I can run the code in the iPhone 15 Pro simulator. Let's see if it runs in the Preview window. I have not succeeded in seeing the app display in the Previews canvas ever since I upgraded to Xcode 15.
Dec ’23