I need reverse(sort in descending order) a NSMutablearray.I tried the following code and it works,but got a warning. How could I remove the warning?
NSMutablearray *resStatusArray;
[resStatusArray sortUsingSelector:@selector(compare:)];
resStatusArray=[[resStatusArray reverseObjectEnumerator] allObjects];
Warning:Incompitable pointer types assigning to 'NSMutablearray*_strong' from ' NSarray *'
user1118321 is correct in the explanation. To fix it, you would create a new mutable array. I suspect this is safer than a cast.
resStatusArray = [NSMutableArray arrayWithArray:[[resStatusArray reverseObjectEnumerator] allObjects]];
The allObjects method returns an NSArray*, not an NSMutableArray*, so the compiler is telling you that your assignment to an NSMutableArray* variable is incorrect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With