NSArray(FWFoundation)

@interface NSArray<__covariant ObjectType> (FWFoundation)

/// 过滤数组元素,返回YES的obj重新组装成一个数组
- (NSArray<ObjectType> *)fw_filterWithBlock:(BOOL (^)(ObjectType obj))block NS_REFINED_FOR_SWIFT;

/// 映射数组元素,返回的obj重新组装成一个数组
- (NSArray *)fw_mapWithBlock:(id _Nullable (^)(ObjectType obj))block NS_REFINED_FOR_SWIFT;

/// 匹配数组第一个元素,返回满足条件的第一个obj
- (nullable ObjectType)fw_matchWithBlock:(BOOL (^)(ObjectType obj))block NS_REFINED_FOR_SWIFT;

/// 从数组中随机取出对象,如@[@"a", @"b", @"c"]随机取出@"b"
@property (nullable, nonatomic, readonly) ObjectType fw_randomObject NS_REFINED_FOR_SWIFT;

@end

Undocumented

  • 过滤数组元素,返回YES的obj重新组装成一个数组

    Declaration

    Objective-C

    - (nonnull NSArray<ObjectType> *)fw_filterWithBlock:
        (nonnull BOOL (^)(ObjectType _Nonnull))block;
  • 映射数组元素,返回的obj重新组装成一个数组

    Declaration

    Objective-C

    - (nonnull NSArray *)fw_mapWithBlock:
        (nonnull id _Nullable (^)(ObjectType _Nonnull))block;
  • 匹配数组第一个元素,返回满足条件的第一个obj

    Declaration

    Objective-C

    - (nullable ObjectType)fw_matchWithBlock:
        (nonnull BOOL (^)(ObjectType _Nonnull))block;
  • 从数组中随机取出对象,如@[@“a”, @“b”, @“c”]随机取出@“b”

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) ObjectType fw_randomObject;