Skip to content

Commit f4a9e4b

Browse files
committed
Add asynchronous API for fetching current user.
1 parent 142edcd commit f4a9e4b

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Parse/PFUser.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ typedef void(^PFUserLogoutResultBlock)(NSError *_Nullable error);
4545
*/
4646
+ (nullable instancetype)currentUser;
4747

48+
/**
49+
*Asynchronously* loads the currently logged in user from disk and returns a task that encapsulates it.
50+
51+
@return The task that encapsulates the work being done.
52+
*/
53+
+ (BFTask<__kindof PFUser *> *)getCurrentUserInBackground;
54+
4855
/**
4956
The session token for the `PFUser`.
5057

Parse/PFUser.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,8 +780,11 @@ + (NSString *)parseClassName {
780780
}
781781

782782
+ (instancetype)currentUser {
783-
PFCurrentUserController *controller = [[self class] currentUserController];
784-
return [[controller getCurrentObjectAsync] waitForResult:nil withMainThreadWarning:NO];
783+
return [[self getCurrentUserInBackground] waitForResult:nil withMainThreadWarning:NO];
784+
}
785+
786+
+ (BFTask<__kindof PFUser *> *)getCurrentUserInBackground {
787+
return [[[self class] currentUserController] getCurrentObjectAsync];
785788
}
786789

787790
- (BOOL)_current {

0 commit comments

Comments
 (0)