objective-c - OC中动态创建可变数组的问题
天蓬老师
天蓬老师 2017-04-26 09:01:49
0
1
458

现有一数组,内有10个元素,已按元素的某一属性排序(比如时间字符串)。现在需要将数组中时间相同的元素取出,放入一个小数组中,再将这些小数组放入一个大数组中,请问该如何操作?最好有代码。此前都因为指针和变量作用域的问题而无法解决。

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(1)
左手右手慢动作

Use NSMutableArray
NSMutableArray * arr2=[NSMutableArray array];//The first step: define an empty variable array

arr2=[NSMutableArray addObject:obj];//The second step is to put the elements you need inside. Your search method is not clearly written, so I only give you a rough idea here

NSMutableArray *arrF=[NSMutableArray addObject:arr2];//Construct a two-dimensional variable array

NSString * str = [[arrF ObjectAtIndex: (large array subscript)] ObjectAtIndex: (small array subscript)]; // Access elements in the array

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!