NSArray+BUUtilities.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // NSMutableArray+Utilities.h
  3. // BUAdSDK
  4. //
  5. // Created by 李盛 on 2018/2/28.
  6. // Copyright © 2018年 bytedance. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. NS_ASSUME_NONNULL_BEGIN
  10. @interface NSMutableArray (BU_Utilities)
  11. - (void)bu_safeAddObject:(id)object;
  12. - (void)bu_safeAddNilObject;
  13. - (void)bu_safeInsertObject:(id)object atIndex:(NSUInteger)index;
  14. - (void)bu_safeInsertObjects:(NSArray *)objects atIndexes:(NSIndexSet *)indexes;
  15. - (void)bu_safeRemoveObject:(id)object;
  16. - (nullable id)bu_objectAtIndexSafely:(NSUInteger)index;
  17. - (void)bu_removeObjectAtIndexSafely:(NSUInteger)index;
  18. @end
  19. @interface NSArray(BU_JSONValue)
  20. - (nullable NSString *)bu_JSONRepresentation:(NSError **)error;
  21. - (void)bu_forEachWithBlock:(void(^)(id item))block;
  22. - (void)bu_forEachWithIndexBlock:(void(^)(id item, NSInteger index))indexBlock;
  23. - (NSArray *)bu_mapWithBlock:(id(^)(id item))block;
  24. - (NSArray *)bu_mapWithIndexBlock:(id(^)(id item, NSInteger index))indexBlock;
  25. - (NSArray *)bu_filterWithConditionBlock:(BOOL(^)(id item))conditionBlock;
  26. - (NSArray *)bu_filterWithIndexConditionBlock:(BOOL(^)(id item, NSInteger index))indexConditionBlock;
  27. - (BOOL)bu_someWithConditionBlock:(BOOL(^)(id item))conditionBlock;
  28. - (BOOL)bu_someWithIndexConditionBlock:(BOOL(^)(id item, NSInteger index))indexConditionBlock;
  29. - (BOOL)bu_everyWithConditionBlock:(BOOL(^)(id item))conditionBlock;
  30. - (BOOL)bu_everyWithIndexConditionBlock:(BOOL(^)(id item, NSInteger index))indexConditionBlock;
  31. - (id)bu_reduceWithBlock:(id(^)(id item1, id item2))block initial:(id)initial;
  32. - (id)bu_findWithConditionBlock:(id(^)(id item))conditionBlock;
  33. - (id)bu_findWithIndexConditionBlock:(id(^)(id item, NSInteger index))indexConditionBlock;
  34. @end
  35. NS_ASSUME_NONNULL_END