tArray and mainArray are pointers. And they refer to the same array in your case. You should use
NSMutableArray *tArray = [mainArray mutableCopy];
to really copy array.
[[NSMutableArray alloc] init]
is not necessary since result will be discarded.