ios - Trying to take objects out of an array, reverse them, and put them back in -


as title says i'm having issue taking objects out of array, flipping them, , putting them in. below code have ends in error

terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[__nsarrayi removeobjectsatindexes:]: unrecognized selector sent instance

i wondering if knew how fix this? here's little more info on how have set up:

the object "peg" nsstring displays "-0.6", "4.36"

globalsortedarray array filled dictionary containing peg object

//declare variables nsmutablearray *negarray = [[nsmutablearray alloc]init]; nsmutableindexset *index = [[nsmutableindexset alloc]init]; int negcount = 0; nsdictionary *forloopdict;   (forloopdict in globalsortedarray)       {           if ([[forloopdict objectforkey:@"peg"] hasprefix:@"-"])           {               [index addindex:negcount];           }           negcount++;       }   nslog(@"%@", negarray);  //    removes objects main array. seems messing up. [globalsortedarray removeobjectsatindexes:index];  //    reverses array nsarray* reversedarray = [[negarray reverseobjectenumerator] allobjects];  //    insters them main array [globalsortedarray insertobjects:negarray atindexes:0]; 

you trying remove item globalsortedarray. nsarray , not mutable.