Allen
Allen

Reputation: 11

How to sort date and display in uitableview header

In my NSMutableArray(xmlParseArray) date are comes from server and the data is

2010-05-14 friday 10june,2010 this is test app this is first application means in xmlParseArray 10 records are coming, i want to show these records according date(sorted date) wise and date on tableview header with format friday 10 june, 2010 format how can i achieve this. any help is appreciated . Thanks in advanced.

Upvotes: 0

Views: 447

Answers (1)

Aravindhan
Aravindhan

Reputation: 15628

If you have an NSMutableArray of objects with a field "beginDate" of type NSDate you can use an NSSortDescriptor as below:

NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"beginDate" ascending:TRUE];
[myMutableArray sortUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
[sortDescriptor release];

Upvotes: 3

Related Questions