FIRSwizzledObject.m 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2017 Google
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import "Private/FIRSwizzledObject.h"
  15. #import "Private/FIRObjectSwizzler.h"
  16. #import "Private/FIRSwizzledObject.h"
  17. NSString *kSwizzlerAssociatedObjectKey = @"fpr_objectSwizzler";
  18. @interface FIRSwizzledObject ()
  19. @end
  20. @implementation FIRSwizzledObject
  21. + (void)copyDonorSelectorsUsingObjectSwizzler:(FIRObjectSwizzler *)objectSwizzler {
  22. [objectSwizzler copySelector:@selector(fpr_objectSwizzler) fromClass:self isClassSelector:NO];
  23. [objectSwizzler copySelector:@selector(fpr_class) fromClass:self isClassSelector:NO];
  24. }
  25. - (instancetype)init {
  26. NSAssert(NO, @"Do not instantiate this class, it's only a donor class");
  27. return nil;
  28. }
  29. - (FIRObjectSwizzler *)fpr_objectSwizzler {
  30. return [FIRObjectSwizzler getAssociatedObject:self key:kSwizzlerAssociatedObjectKey];
  31. }
  32. #pragma mark - Donor methods
  33. - (Class)fpr_class {
  34. return [[self fpr_objectSwizzler] generatedClass];
  35. }
  36. @end