Reputation: 111
I try to set titleTextAttributes
for UINavigationBar.appearance()
instance. But XCode doesn't list it in autocomplete drop down list:
However I can manually type titleTextAttributes
and code builds successfully. What does this happen?
Upvotes: 3
Views: 192
Reputation: 534950
Well, what's the class of UINavigationBar.appearance()
? It's UIAppearance — not UINavigationBar. It's a proxy object, not an actual navigation bar. So it has no titleTextAttributes
property. It merely stores your commands as an invocation and then invokes that on any future actual navigation bars that show up in your app.
Thus, no UINavigationBar properties appear in the completion for UINavigationBar.appearance()
. It's a pity, but it's not incomprehensible.
It's true that the compiler helps you with this by interpreting UINavigationBar.appearance()
as if it were a UINavigationBar. However, that's a relatively new feature; I remember back when it didn't happen, and the compiler would just let you send any message to the appearance proxy (and then crash). So, it seems that this compiler feature has not been carried over into Xcode's text completion engine.
Upvotes: 3