UITableViewCell+MAC.m 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // UITableViewCell+MAC.m
  3. // WeiSchoolTeacher
  4. //
  5. // Created by MacKun on 15/12/18.
  6. // Copyright © 2015年 MacKun. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import <objc/runtime.h>
  10. #import "UITableViewCell+MAC.h"
  11. @implementation UITableViewCell(MAC)
  12. - (void)setIsSelect:(BOOL)isSelect{
  13. objc_setAssociatedObject(self, @"isSelect", @(isSelect), OBJC_ASSOCIATION_ASSIGN);
  14. }
  15. - (BOOL)isSelect{
  16. return [objc_getAssociatedObject(self, @"isSelect") boolValue];
  17. }
  18. /**
  19. * @brief 加载同类名的nib
  20. *
  21. * @return cell
  22. */
  23. +(id)nibCell{
  24. // NSArray *nib = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil];
  25. //
  26. // return [nib objectAtIndex:0];
  27. return [[[UINib nibWithNibName:NSStringFromClass([self class]) bundle:nil]instantiateWithOwner:nil options:nil] objectAtIndex:0];
  28. }
  29. + (NSString*)cellIdentifier {
  30. return NSStringFromClass(self);
  31. }
  32. + (id)loadFromCellStyle:(UITableViewCellStyle)cellStyle {
  33. return [[self alloc] initWithStyle:cellStyle reuseIdentifier:NSStringFromClass(self)];
  34. }
  35. @end