views:

101

answers:

1

hello all , I have NSMutableArray that i need to sort . to do so i use sortedArrayUsingSelector this function return me NSArray with the objects sorted.

my question is: if i want to sort the original array again do i need to release the previous sorted list that i got or just to sort it again ??

thanks

A: 

The original an array and sorted array (the array that gets created by get created from sortedArrayUsingSelector) are different objects. So yes, if you won't use the 'previous sorted list' again, release it.

Ross
Are you sure i need to use the release method?because 1.when i get the sorted array i didnt use alloc or new i just give pointer of nsarray to the sort method.and 2.when i use release method the app crash.
Amir
The sorted array will be release automatically as it will be added to the autorelease pool. So you won't need to use its release method. Unless you previously have used its retain method.
Ross