NSArray(FWApplication)

@interface NSArray <__covariant ObjectType>(FWApplication)

NSArray分类

Note

如果需要数组weak引用元素,使用[NSValue valueWithNonretainedObject:object]即可
  • 从数组中按照权重随机取出对象,如@[@“a”, @“b”, @“c”]按照@[@0, @8, @02]大概率取出@“b",不会取出@"a”

    Declaration

    Objective-C

    - (nullable ObjectType)fw_randomObject:(nonnull NSArray *)weights;

    Parameters

    weights

    权重数组,按整数计算

    Return Value

    随机对象

  • 获取翻转后的新数组

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly) NS_REFINED_FOR_SWIFT NSArray<ObjectType> *fw_reverseArray;

    Return Value

    翻转后的数组

  • 获取打乱后的新数组

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly) NS_REFINED_FOR_SWIFT NSArray<ObjectType> *fw_shuffleArray;

    Return Value

    打乱后的数组

  • 数组中是否含有NSNull值

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL fw_includeNull;

    Return Value

    是否含有NSNull

  • 递归移除数组中NSNull值

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly) NS_REFINED_FOR_SWIFT NSArray<ObjectType> *fw_removeNull;

    Return Value

    不含NSNull的数组

  • 移除数组中NSNull值

    @praram recursive 是否递归

    Declaration

    Objective-C

    - (nonnull NSArray<ObjectType> *)fw_removeNullRecursive:(BOOL)recursive;

    Return Value

    不含NSNull的数组