将 NSMutableArray 拆分为其他 NSMutableArray [英] Split an NSMutableArray into other NSMutableArrays

查看:84
本文介绍了将 NSMutableArray 拆分为其他 NSMutableArray的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含 50 个条目的 NSMutableArray - 有没有什么简单的方法可以将其拆分为 5 个 NSMutableArrays,每个 NSMutableArrays 每个包含 10 个条目.

I have an NSMutableArray with 50 entries - is there any easy way to split this into 5 NSMutableArrays each with 10 entries each.

推荐答案

我写了一个短函数 不久前就这样做了.它的要点是循环一个数组,在循环索引处以您想要的子数组数为模填充任意数组,直到用完项目.

I wrote a short function to do this a while ago. The gist of it is to loop an array filling an arbitrary array at the loop index modulo the number of subarrays you want until you run out of items.

这篇关于将 NSMutableArray 拆分为其他 NSMutableArray的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆