UITableView+CellClass.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // MACBaseCell.h
  3. // MACProject
  4. //
  5. // Created by MacKun on 15/12/18.
  6. // Copyright © 2015年 MacKun. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. @class MACBaseCell;
  10. @class CellDataAdapter;
  11. @interface CellClassType : NSObject
  12. @property (nonatomic, strong) NSString *classString;
  13. @property (nonatomic, strong) NSString *reuseIdentifier;
  14. /**
  15. * Create a object that contain the classString and the reuseIdentifier.
  16. *
  17. * @param classString Class string.
  18. * @param reuseIdentifier Cell reuseIdentifier
  19. *
  20. * @return CellClassType Object.
  21. */
  22. + (instancetype)cellClassTypeWithClassString:(NSString *)classString reuseIdentifier:(NSString *)reuseIdentifier;
  23. /**
  24. * The classString is the same with the reuseIdentifier.
  25. *
  26. * @param classString Class string.
  27. *
  28. * @return CellClassType Object.
  29. */
  30. + (instancetype)cellClassTypeWithClassString:(NSString *)classString;
  31. @end
  32. NS_INLINE CellClassType *cellClass(NSString *classString, NSString *reuseIdentifier) {
  33. return [CellClassType cellClassTypeWithClassString:classString reuseIdentifier:reuseIdentifier.length <= 0 ? classString : reuseIdentifier];
  34. }
  35. @interface UITableView (CellClass)
  36. /**
  37. * Register cells class.
  38. *
  39. * @param cellClasses CellClassType object's array.
  40. */
  41. - (void)registerCellsClass:(NSArray <CellClassType *> *)cellClasses;
  42. - (MACBaseCell *)dequeueAndLoadContentReusableCellFromAdapter:(CellDataAdapter *)adapter indexPath:(NSIndexPath *)indexPath;
  43. - (MACBaseCell *)dequeueAndLoadContentReusableCellFromAdapter:(CellDataAdapter *)adapter indexPath:(NSIndexPath *)indexPath
  44. controller:(UIViewController *)controller;
  45. @end