ios Array 数组的valueForkeypath 快速的处理以及数组的拆分

来源:互联网 发布:mac系统修复软件 编辑:程序博客网 时间:2024/06/14 16:10

http://www.jianshu.com/p/e71cec144966

确实很方便

-(void)splitArray{
    if(self.unReadmsgModule){
        if (self.module.showingMessages.count>self.unReadmsgModule.unReadmsgCount) {
            NSIndexSet * unreadIndexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(self.module.showingMessages.count-self.unReadmsgModule.unReadmsgCount, self.unReadmsgModule.unReadmsgCount)];
            NSIndexSet * readIndexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, self.module.showingMessages.count-self.unReadmsgModule.unReadmsgCount)];
            self.module.unReadMsgArray = [[NSMutableArray alloc]initWithArray:[self.module.showingMessages objectsAtIndexes:unreadIndexSet]];
            self.module.readMsgArray = [[NSMutableArray alloc]initWithArray:[self.module.showingMessages objectsAtIndexes:readIndexSet]];
            
        }else{
            self.module.unReadMsgArray = self.module.showingMessages;
        }
    }

数组的拆分