美文网首页
取出数组中指定范围位置的子数组

取出数组中指定范围位置的子数组

作者: Louis_hey | 来源:发表于2016-06-14 23:02 被阅读374次
    #import "ViewController.h"
    
    @interface ViewController ()
    
    /** <#注释#> */
    
    @property(nonatomic, strong) NSMutableArray *arrM;
    
    @end
    
    @implementation ViewController
    
    -(NSMutableArray *)arrM{
    
    if (_arrM == nil) {
    
    _arrM = [NSMutableArray array];
    
    }
    
    return _arrM;
    
    }
    
    - (void)viewDidLoad {
    
    [super viewDidLoad];
    
    NSArray *larger = @[@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10"];
    
    [self.arrM addObjectsFromArray:[larger subarrayWithRange:NSMakeRange(0, 3)]];
    
    //[larger subarrayWithRange:NSMakeRange(0, 3)];
    NSLog(@"%@--%zd",self.arrM,self.arrM.count);
    
    }
    
    @end
    
     NSArray *larger = @[@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10"];
       [self.arrM addObjectsFromArray:[larger subarrayWithRange:NSMakeRange(0, 3)]];
        //[larger subarrayWithRange:NSMakeRange(0, 3)];
        NSLog(@"%@--%zd",self.arrM,self.arrM.count);
    

    相关文章

      网友评论

          本文标题:取出数组中指定范围位置的子数组

          本文链接:https://www.haomeiwen.com/subject/kriudttx.html