There is a function that creates random text let s = randString() . Text is written to the text field.

How to find this text (variable s on the screen?)

  • write the variable to which field the text was transferred to - Max Mikheyenko
  • one
    If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

 var viewToFind:UITextView; for (_, item) in self.view.subviews.enumerate() { if(item is UITextView) { if((item as! UITextView).text == "test text") { viewToFind = item as! UITextView print(viewToFind.text) } } } 

go through all the self-view self.view ; if you need to search further down the tree, write recursion