You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.2 KiB

  1. //
  2. // FLEXTableViewSection.h
  3. // FLEX
  4. //
  5. // Created by Tanner Bennett on 7/11/19.
  6. // Copyright © 2019 Flipboard. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. NS_ASSUME_NONNULL_BEGIN
  10. /// A protocol for arbitrary case-insensitive pattern matching
  11. @protocol FLEXPatternMatching <NSObject>
  12. /// @return YES if the receiver matches the query, case-insensitive
  13. - (BOOL)matches:(NSString *)query;
  14. @end
  15. @interface FLEXTableViewSection<__covariant ObjectType> : NSObject
  16. + (instancetype)section:(NSInteger)section title:(NSString *)title rows:(NSArray<ObjectType<FLEXPatternMatching>> *)rows;
  17. @property (nonatomic, readonly) NSInteger section;
  18. @property (nonatomic, readonly) NSString *title;
  19. @property (nonatomic, readonly) NSArray<ObjectType<FLEXPatternMatching>> *rows;
  20. @property (nonatomic, readonly) NSInteger count;
  21. /// @return A new section containing only rows that match the string,
  22. /// or nil if the section was empty and no rows matched the string.
  23. - (nullable instancetype)newSectionWithRowsMatchingQuery:(NSString *)query;
  24. @end
  25. @interface FLEXTableViewSection<__covariant ObjectType> (Subscripting)
  26. - (ObjectType)objectAtIndexedSubscript:(NSUInteger)idx;
  27. @end
  28. NS_ASSUME_NONNULL_END