Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

xcode how to know which textfield is selected

class ViewController : UIViewController, UITextFieldDelegate {

   var activeTextField = UITextField()

   // Assign the newly active text field to your activeTextField variable
   func textFieldDidBeginEditing(textField: UITextField) {

        self.activeTextField = textField
   }

   // Call activeTextField whenever you need to
   func anotherMethod() {

       // self.activeTextField.text is an optional, we safely unwrap it here
       if let activeTextFieldText = self.activeTextField.text {
             print("Active text field's text: (activeTextFieldText)")
             return;
       }

       print("Active text field is empty")
   }
}
Comment

PREVIOUS NEXT
Code Example
Swift :: average in array swift 
Swift :: user defaults swift 
Swift :: uitextview text alignment 
Swift :: swiftui font add 
Swift :: swift struct 
Swift :: record permission swift 4 
Swift :: swift remove all pins from mapkit 
Swift :: how to clear text file swift 
Swift :: Play Video in AVPlayer Sample Code Swift 
Swift :: swift extension Array with element 
Swift :: Single Line Comment 
Swift :: latex tall parentheses 
Swift :: nil coalescing swift 
Swift :: two variable sum in swift 
Swift :: declare variable in swif 
Swift :: Swift Closure as function parameter 
Swift :: UINavigationBar turns black 
Swift :: get absolution position of view in swift 
Swift :: how to check if something is in a set in swift 
Swift :: map vs compactmap in swiftui 
Swift :: Associate Multiple Values Swift 
Swift :: Swift Things to Remember About Swift Range 
Swift :: protocol oriented programming swift github Basic 
Swift :: corner radius with animation swift 
Swift :: bind object 
Swift :: Adapt sfsymbol to frame swiftui 
Ruby :: how to match email in regex in ruby 
Ruby :: rails image tag 
Ruby :: Your Ruby version is 2.6.8, but your Gemfile specified 2.7.5 
Ruby :: how to down a particular migration in rails 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =