GDTCORDataFuture.m 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright 2019 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 "GDTCORLibrary/Private/GDTCORDataFuture.h"
  17. @implementation GDTCORDataFuture
  18. - (instancetype)initWithFileURL:(NSURL *)fileURL {
  19. self = [super init];
  20. if (self) {
  21. _fileURL = fileURL;
  22. }
  23. return self;
  24. }
  25. - (BOOL)isEqual:(id)object {
  26. return [self hash] == [object hash];
  27. }
  28. - (NSUInteger)hash {
  29. // In reality, only one of these should be populated.
  30. return [_fileURL hash];
  31. }
  32. #pragma mark - NSSecureCoding
  33. /** Coding key for _fileURL ivar. */
  34. static NSString *kGDTCORDataFutureFileURLKey = @"GDTCORDataFutureFileURLKey";
  35. + (BOOL)supportsSecureCoding {
  36. return YES;
  37. }
  38. - (void)encodeWithCoder:(nonnull NSCoder *)aCoder {
  39. [aCoder encodeObject:_fileURL forKey:kGDTCORDataFutureFileURLKey];
  40. }
  41. - (nullable instancetype)initWithCoder:(nonnull NSCoder *)aDecoder {
  42. self = [self init];
  43. if (self) {
  44. _fileURL = [aDecoder decodeObjectOfClass:[NSURL class] forKey:kGDTCORDataFutureFileURLKey];
  45. }
  46. return self;
  47. }
  48. @end