I’ve got the following code, which, when a table column is clicked, will sort the table:
NSArray *temp = [NSArray arrayWithArray:allAssignments]; [allAssignments removeObjectsInArray:temp];
NSSortDescriptor *nameDescriptor=[[[NSSortDescriptor alloc] initWithKey:[tableColumn identifier] ascending:YES selector:@selector(compare:)] autorelease];
NSArray *sortDescriptors=[NSArray arrayWithObjects:nameDescriptor, nil];
temp = [temp sortedArrayUsingDescriptors:sortDescriptors]; [allAssignments addObjectsFromArray:temp];
Use NSDate
Yeah, I thought I might get a response like that. I’m not sure why I stored them as strings to begin with, but I’ll have to change them and my program to NSDate. Now, I’m saving the items as NSDates like so: [newDictionary setObject:[NSDate dateWithNaturalLanguageString:[dateField stringValue]] forKey:@”Date”]; and then saving the Dictionary item to the UserPrefs. The item is saving correctly, but my NSTableView isn’t reading the Date back correctly, either with or without a formatter. What is going on here?