Person+addProperty.m 486 B

123456789101112131415161718192021222324
  1. //
  2. // Person+addProperty.m
  3. // RunTimeThing
  4. //
  5. // Created by Linzhixiao on 16/4/15.
  6. // Copyright © 2016年 Linzhixiao. All rights reserved.
  7. //
  8. #import "Person+addProperty.h"
  9. #import <objc/runtime.h>
  10. @implementation Person (addProperty)
  11. char eName;
  12. - (void)setEnglishName: (NSString *)englishName {
  13. objc_setAssociatedObject(self, &eName, englishName, OBJC_ASSOCIATION_COPY_NONATOMIC);
  14. }
  15. - (NSString *)englishName {
  16. return objc_getAssociatedObject(self, &eName);
  17. }
  18. @end