Is there a way to make a trigger (in Swift) that fires and does something whenever a certain element (like when app.staticTexts["sometitle"]
) exists and is accessible by Accessibility. In other languages, "stand-by" loops are considered bad practice, so there are latches and callbacks (on creation). Is there something similar in Swift?
Asked
Active
Viewed 76 times
-1

SalmonKiller
- 2,183
- 4
- 27
- 56
-
I'm not sure what you are trying to do. Could you explain what you are trying to use this to do? – David Rönnqvist Jul 20 '15 at 06:38
-
@DavidRönnqvist Let's say, I want to do XCUITest tests, and I have a dynamically added view (ie added and then removed) with a textfield in it. I want a certain method to fire when that view is added. – SalmonKiller Jul 20 '15 at 15:02
1 Answers
0
While not exactly what you're looking for, UIView
provides a pair of methods, -willMoveToWindow
and -didMoveToWindow:
, that might serve your purposes. Working from the other end, you might consider implementing -didAddSubview:
on the containing view or window. For more information, refer to the documentation for UIView.

Justin
- 20,509
- 6
- 47
- 58