I have an abstract class AuthResult
that has property - Token
model class.
#import <Foundation/Foundation.h>
@class Token;
@interface AuthResult : NSObject
+ (instancetype)sharedInstance; // designated initializer
@property (readwrite, strong, nonatomic) Token *token;
@property (readwrite, nonatomic) BOOL isAuthorized;
@end
Token
model class, in his turn, has 5 properties within:
#import <Foundation/Foundation.h>
@interface Token : NSObject
@property (readwrite, strong, nonatomic) NSString *accessToken;
@property (readwrite, strong, nonatomic) NSDate *expirationDate;
@property (readwrite, strong, nonatomic) NSString *tokenType;
@property (readwrite, strong, nonatomic) NSString *scope;
@property (readwrite, strong, nonatomic) NSString *refreshToken;
@end
My goal is to override setter method in AuthResult
class in order to handle different cases. E.g. after token refresh request it has refreshToken
property empty so I do not need to erase it.
I tried this approach - setter in AuthResult
class:
- (void)setToken:(Token *)token {
_token.accessToken = token.accessToken;
_token.expirationDate = token.expirationDate;
_token.tokenType = token.tokenType;
_token.scope = token.scope;
if (token.refreshToken != nil) {
// DO NOT OVERRIDE REFRESH_TOKEN HERE (after refresh token request it comes as null)
_token.refreshToken = token.refreshToken;
}
}
But it doesn't work. It makes token object in AuthResult
class always empty.
As I see - I don't have an access to object properties. I do have access to instance variable - "_token" object. But I do not have access to HIS properties.
Please advice. Thank you