Answer the question
In order to leave comments, you need to log in
How do nested functions work?
I often use libraries and frameworks, but I don't fully understand how they work.
Question 1:
How can you get a variable from a function, and even an optional one, and then get a variable from it?
I can't imagine how this should be described.
For example this expression:
Auth.auth().currentUser?.providerData[indexPath.row] ( пример из документации Firebase )
@objc protocol
and nowhere else, but here is something like an optional method. How can this be described, and how does it work in general? if FUIAuth.defaultAuthUI()?.handleOpen(url, sourceApplication: sourceApplication) ?? false {
return true
}
Answer the question
In order to leave comments, you need to log in
Good day. The question is a little strange.
It is enough to go here and find out that the method auth
only returns an instance of the class. FIRAuth
Actually, all of yours currentUser
are present here. I think now there should be no questions.
@implementation FIRAuth {
/** @var _currentUser
@brief The current user.
*/
FIRUser *_currentUser;
/** @var _firebaseAppName
@brief The Firebase app name.
*/
NSString *_firebaseAppName;
/** @var _listenerHandles
@brief Handles returned from @c NSNotificationCenter for blocks which are "auth state did
change" notification listeners.
@remarks Mutations should occur within a @syncronized(self) context.
*/
NSMutableArray<FIRAuthStateDidChangeListenerHandle> *_listenerHandles;
/** @var _keychain
@brief The keychain service.
*/
FIRAuthKeychain *_keychain;
/** @var _lastNotifiedUserToken
@brief The user access (ID) token used last time for posting auth state changed notification.
*/
NSString *_lastNotifiedUserToken;
/** @var _autoRefreshTokens
@brief This flag denotes whether or not tokens should be automatically refreshed.
@remarks Will only be set to @YES if the another Firebase service is included (additionally to
Firebase Auth).
*/
BOOL _autoRefreshTokens;
/** @var _autoRefreshScheduled
@brief Whether or not token auto-refresh is currently scheduled.
*/
BOOL _autoRefreshScheduled;
/** @var _isAppInBackground
@brief A flag that is set to YES if the app is put in the background and no when the app is
returned to the foreground.
*/
BOOL _isAppInBackground;
/** @var _applicationDidBecomeActiveObserver
@brief An opaque object to act as the observer for UIApplicationDidBecomeActiveNotification.
*/
id<NSObject> _applicationDidBecomeActiveObserver;
/** @var _applicationDidBecomeActiveObserver
@brief An opaque object to act as the observer for
UIApplicationDidEnterBackgroundNotification.
*/
id<NSObject> _applicationDidEnterBackgroundObserver;
}
class Auth {
class func auth() -> FIRAuth { ... }
...
}
class FIRAuth {
var currentUser: FIRUser?
...
}
class FIRUser {
var providerData: [Int : {что-то}]
...
}
Auth.auth().currentUser?.providerData[indexPath.row]
FUIAuth.defaultAuthUI()
returns an optional. Why not continue the chain. We continue:FUIAuth.defaultAuthUI()?.handleOpen(url, sourceApplication: sourceApplication)
But oddly enough, this method also returns an optional, and we just want to protect ourselves from this and say that if the last method also has an optional, then return the right side, that is, false. As a result, we get the big picture:FUIAuth.defaultAuthUI()?.handleOpen(url, sourceApplication: sourceApplication) ?? false
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question