没有CurrentUser属性,
我建议使用下一个机制:
1)创建单例
本地存储控制器.h
@interface LocalStorageController : NSObject
+ (instancetype)shared;
@property (nonatomic, strong) QBUUser *qbUser;
@end
本地存储控制器.m
#import "LocalStorageController.h"
@implementation LocalStorageController
@synthesize qbUser = _qbUser;
+ (instancetype)shared
{
static LocalStorageController *instance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [[LocalStorageController alloc] init];
});
return instance;
}
@end
2)登录LoginViewController.m后保存QB用户
@implementation LoginViewController
- (void)login
{
[QBUsers logInWithUserLogin:@"qbUser1" password:@"qbUser1" delegate:self];
}
- (void)completedWithResult:(Result *)result{
if([result isKindOfClass:QBUUserResult.class] && result.success){
QBUUserResult *res = (QBUUserResult *)result;
// save user
[LocalStorageController shared].qbUser = res.user;
}
}
3)在您的用户的任何地方使用
ViewController1.m
- (void)doSomething{
QBUUser *currentUser = [LocalStorageController shared].qbUser;
}
视图控制器2.m
- (void)doSomething{
QBUUser *currentUser = [LocalStorageController shared].qbUser;
}