Looking at this image, you can see that a UIView loaded from a nib has a "File Owner"
Notice in the xib, Apple has labelled something "File Owner".
So, open Xcode, open any xib, look at Placeholders, and look directly underneath, to see:
"File Owner".
In this particular example, the "xib-file-owner" happens to be the class LoginScreen.
So, at run time, for a specific thing created by this xib, the "was-xib-file-owner" (to coin a phrase) will in fact be:
It will be: some particular instance of the class LoginScreen.
Now at run time. Obviously, in a UIView, with every UIButton, you can simply call
[self.someButton sendActionsForControlEvents:UIControlEventTouchUpInside ];
and you get to indeed "go to", precisely:
You go to: that instance of the class LoginScreen.
{Note - OF COURSE, the UIButton could be pointed anywhere at all. I am asking about the case where we know for a fact the UIButton is indeed pointing to the "was-xib-file-owner" of the UIButton.}
In fact, the method allTargets
will indeed return that target (in this case some instance of the class LoginScreen) as part of the N target(s) it returns, and indeed the selector(s), etc etc.
I'm not good enough to write code for allTargets, NSSet, etc.
Can someone show me how to extract, using allTargets and some computer code, the instance of the class LoginScreen? ie the running instance of the "was-xib-file-owner" seen in the xib? Cheers.
Later:
bizarrely, the answer to this question is, essentially and generally:
[self.allTargets anyObject]
since, if created from the xib there will only be the one, and, it is precisely what is described in bold above. To repeat: OF COURSE, the UIButton could be pointed ANYWHERE AT ALL. I am asking about the case where we know for a fact the UIButton is indeed pointing to the "was-xib-file-owner" of the UIButton.
In that ("normal") case the answer is indeed just that surprisingly simple -- [self.allTargets anyObject].
there is no file owner (as seen in IB) known to views at runtime. The information about the file owner isn't there. Closest you can do is check the target's class:
or just assume target is owner