Без опису

FIRAuthDataResult.m 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "FIRAuthDataResult_Internal.h"
  17. #import "FIRAdditionalUserInfo.h"
  18. #import "FIRUser.h"
  19. NS_ASSUME_NONNULL_BEGIN
  20. @implementation FIRAuthDataResult
  21. /** @var kAdditionalUserInfoCodingKey
  22. @brief The key used to encode the additionalUserInfo property for NSSecureCoding.
  23. */
  24. static NSString *const kAdditionalUserInfoCodingKey = @"additionalUserInfo";
  25. /** @var kUserCodingKey
  26. @brief The key used to encode the user property for NSSecureCoding.
  27. */
  28. static NSString *const kUserCodingKey = @"user";
  29. - (nullable instancetype)initWithUser:(nullable FIRUser *)user
  30. additionalUserInfo:(nullable FIRAdditionalUserInfo *)additionalUserInfo {
  31. self = [super init];
  32. if (self) {
  33. _additionalUserInfo = additionalUserInfo;
  34. _user = user;
  35. }
  36. return self;
  37. }
  38. #pragma mark - NSSecureCoding
  39. + (BOOL)supportsSecureCoding {
  40. return YES;
  41. }
  42. - (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
  43. FIRUser *user =
  44. [aDecoder decodeObjectOfClass:[FIRUser class] forKey:kUserCodingKey];
  45. FIRAdditionalUserInfo *additionalUserInfo =
  46. [aDecoder decodeObjectOfClass:[FIRAdditionalUserInfo class]
  47. forKey:kAdditionalUserInfoCodingKey];
  48. return [self initWithUser:user additionalUserInfo:additionalUserInfo];
  49. }
  50. - (void)encodeWithCoder:(NSCoder *)aCoder {
  51. [aCoder encodeObject:_user forKey:kUserCodingKey];
  52. [aCoder encodeObject:_additionalUserInfo forKey:kAdditionalUserInfoCodingKey];
  53. }
  54. @end
  55. NS_ASSUME_NONNULL_END