(Get ready to testify that the newbie is very, very confused by what I suppose to be the main form of logic that my brain is trying to understand).
At the moment I have a .plist file. In the βKeyβ column there are event names (this is just fictitious content at the moment), and in the βValueβ column there are dates in this format: 07/19/2012. Each line is of type "string".
In the viewDidLoad method, I use the following code:
NSString *theFile = [[NSBundle mainBundle] pathForResource:@"dates" ofType:@"plist"]; theDates = [[NSDictionary alloc] initWithContentsOfFile:theFile]; theDatesList = [theDates allKeys];
This loads the plist file into the dictionary, then I load the keys into an array that I found out to populate the UITableView
, especially with this code in the cellForRowAtIndexPath
method:
NSString *eventFromFile = [theDatesList objectAtIndex:indexPath.row]; NSString *dateFromFile = [theDates objectForKey:[theDatesList objectAtIndex:indexPath.row]];
But now I'm confused about how I can arrange UITableView
cells depending on which dates are fastest? So, the cell for July 19th will appear before August 21st, regardless of the order in which it is inside the plist file.
In UITableViewCell
I was able to calculate the number of days between the current date and the date defined within the plist. What is this code:
But I really don't know what I'm doing. Can someone give me a push in the right direction? I looked at the NSSortDescriptors
method and sortedArrayUsingSelector
, which seems to matter, but the effect of the actual implementation has left me stuck for the last six hours. Or maybe this is the wrong way. As I said, I am very confused.
Thanks.
source share