
I have 5 NSMutableArrays in cell. I need to sort cells by one value.
Example I need to sort cell by time.
[MyArray1 sortUsingSelector:@selector(compare:)];
but how I will be with other 4 NSMutableArray in cell?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s not a good idea to store data for your cells in 5 arrays, don’t separate them; create a data container class, store all values for each cell inside one data container object and then you can sort your array with data containers by one of the values.
e.g.:
DataContainer.h:
DataContainer.m:
Then you can create your
DataContainer‘s (one for each cell) and store them in oneNSMutableArray.e.g.:
To sort this array, use:
and then use them in your
cellForRowAtIndexPath:Notice that this code is suitable if you’re using ARC (Automatic Reference Counting) for your project; if you’re not using ARC, then you need to change
strongtoretainin property definitions and addrelease‘s to needed places to avoid memory leaks.