I set up an outlet for a text view via Interface Builder. The text view loads fine, however I can't access any of the properties of it programmatically because the outlet is always nil
.
When does it instantiate? Even after my applicationDidFinishLoading
gets called, it's still not "alive" or unarchived.
An outlet doesn't instantiate because an outlet is a variable (or property).
The objects in a nib are instantiated when that nib is loaded, and they are assigned to each outlet as immediately as possible afterward, after the objects are created but before awakeFromNib
is sent to all relevant objects.
In other words, nib loading does all of the following, in this order:
view
outlet to a top-level view.)awakeFromNib
to objects in the nib, and (in Cocoa) also to the File's Owner (e.g., window controller).Your question is answered by #2.
The Resource Programming Guide has more information. The details are subtly different between Cocoa and Cocoa Touch, particularly as regard which objects are sent awakeFromNib
messages and which ones aren't.
When does it instantiate? Even after my
applicationDidFinishLoading
gets called, it's still not "alive" or unarchived.
The text view isn't?
It probably is and you just didn't connect the outlet. Check this in the nib.
Another possibility: You created the text view in another nib, not the one where the app delegate is created (if you even created the app delegate in a nib at all), and you didn't connect the view to the outlet of the right object. Perhaps you created a second app delegate in the text view's nib; this app delegate is not actually the app's delegate, which is why the real app delegate does not see the text view—you gave the text view to the impostor, not the real McCoy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With