Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to copy the required Items of NSMutableArray to NSArray [duplicate]

I have NSMutableArray of Results it has 6 items. I want to copy the first three contents to another NSArray.

like image 573
Nazia Jan Avatar asked Nov 30 '25 16:11

Nazia Jan


1 Answers

Just use subarrayWithRange::

NSMutableArray *oldArray = ... // the mutable array with the 6 objects
NSArray *result = [oldArray subarrayWithRange:NSMakeRange(0, MIN(3, oldArray.count))];
like image 142
rmaddy Avatar answered Dec 02 '25 05:12

rmaddy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!