A-IOSHelper [Animax Helper]

This is a scaffold library and the aid of the project is providing all foundation functions for IOS developer to build app easier.
Stories in Ready Build Status


Project maintained by Animaxx Thanks mattgraham for original Theme

Collection

Collection helper imitates the Linq in .Net to provide such Where, Any, Skip, and other assisting functions for NSArray and NSDictionary.



Contents

Where example

    NSArray* _list = @[@1,@2,@3,@4,@5,@6,@7,@8,@9,@10];
            //convert the type of x to your item's type
    NSArray* result = [_list A_Where:^bool(NSNumber* x) {
        return [x integerValue] > 5;
    }];
    // result: 6,7,8,9,10
    


Any example

    NSArray* _list = @[@1,@2,@3,@4];
    [_list A_Any:^bool(NSNumber* x) {
        return [x integerValue] % 2 == 0;
    }]; // return YES
    [_list A_Any:^bool(NSNumber* x) {
        return [x integerValue] % 5 == 0;
    }]; // return NO
        


Skip and Take Example

    NSArray* _list = @[@1,@2,@3,@4,@5,@6,@7,@8,@9,@10];
    NSArray* result = [[_list A_Skip:4] A_Take:3];
    // result:5,6,7
        


Reverse example

    NSArray* _list = @[@1,@2,@3,@4,@5,@6,@7,@8,@9,@10];
    NSArray* _test = [_list A_Reverse];
    // result: 10,9,8,7,6,5,4,3,2,1
        


Swap example

    NSMutableArray* demo1 = [[NSMutableArray alloc] initWithArray:@[@"A",@"B",@"C"]];
    NSMutableArray* demo2 = [[NSMutableArray alloc] initWithArray:@[@"1",@"2",@"3"]];

    [demo1 A_Swap:demo2];
    // demo1: 1,2,3
    // demo2: A,B,C


First and last match Example

    NSArray* _list = @[@1,@2,@3,@4,@5,@6,@7,@8,@9,@10];
    NSNumber* _first = [_list A_FirstOrNil:^bool(NSNumber* x) {
        return [x integerValue] % 2 ==0;
    }]; // _first: 2
    NSNumber* _last = [_list A_LastOrNil:^bool(NSNumber* x) {
        return [x integerValue] % 2 ==0;
    }]; // _last: 10
        


Combine array to dictionary Example

    NSArray* _list = @[@"A",@"B",@"C"];
    NSDictionary* result1 = [_list A_CombineKeys:@[@1,@2,@3]];
    // result1: 1:A 2:B 3:C

    NSDictionary* result1 = [_list A_CombineValues:@[@1,@2,@3]];
    // result2: A:1 B:2 C:3