Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

Sorting Custom Cells by NSArray?

Objective ZeroObjective Zero Posts: 1,231Registered Users
Hey,

I am loading my tableview like this:
TCell *cell = (TCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
NSArray *array = [[NSBundle mainBundle] loadNibNamed:@\"TCell\" owner:self options:nil];
cell = (TCell *)[array objectAtIndex:0];
}


In each custom cell, there is text in a uilabel that is loaded from a nsmutablearray.
One of the nsmutablearray's holds int's
The other nsmutablearray's holds nsdate in an unformatted form

I am trying to sort the cells based upon the highest int or the newest date. I got as far as getting the highest int in the array and getting the newest date but I am not sure how to reorder the cells in the way I explained. If anyone can help maybe make my current code better or help me redorder the rows that would be great. Also in the second if statement, how would I make a loop to loop through the array putting the highest int on top and it will ascend down? I am not asking for code but just some help/tips.

Here is my current code:


- (IBAction)sortbartouchdown {

TestAppDelegate *appDelegate = (TestAppDelegate *)[[UIApplication sharedApplication] delegate];

//Date
if(sortbar.selectedSegmentIndex == 0){

//Get Date and sort from newest
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@\"beginDate\" ascending:TRUE];
[appDelegate.Dates sortUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
[sortDescriptor release];

//Now reorder tableview using the code above and animated
//How would I do this?

}

//Score
if(sortbar.selectedSegmentIndex == 1){

sortedScoreArray = [appDelegate.Score sortedArrayUsingSelector:@selector(intValue)];
//Move cells to appropriate places and animated
[sortedScoreArray lastObject];

}


}


Thanks!
Post edited by Objective Zero on

Replies

Sign In or Register to comment.