类中添加name属性:
(nonatomic,copy) NSString *name;
static const void *kViewControllerName = &kViewControllerName;
- (void)setName:(NSString *)name {
objc_setAssociatedObject(self, kViewControllerName, name, OBJC_ASSOCIATION_COPY_NONATOMIC);
}
- (NSString *)name {
NSString *myName = objc_getAssociatedObject(self, kViewControllerName);
return myName;
}