Hi,
I get a bunch of objects from core data and put them into an array, like this:
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"completed" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
NSMutableArray *sortedIngredients = [[NSMutableArray alloc] initWithArray:[event.tags allObjects]];
[sortedIngredients sortUsingDescriptors:sortDescriptors];
NSPredicate *predicate = [NSPredicate predicateWithFormat: @"completed == nil"];
[sortedIngredients filterUsingPredicate: predicate];
NSArray *incompletedArray = [[NSArray alloc] initWithArray: sortedIngredients];
[sortDescriptor release];
[sortDescriptors release];
[sortedIngredients release];
I want the object that are older then 2 days to be deleted from core data.
By using this function, I can get the date when an object was created:
NSLog(@"Object at index: %@", [incompletedArray objectAtIndex: 1]);
The output is this:
2009-09-30 17:48:42.490 TaggedLocations[11428:207] String: (entity: Tag; id: 0x3c39ba0 ; data: { completed = nil; creationDate = 2009-09-30 17:45:24 -1000; events = 0x3e10060 ; info = nil; name = 1; })
I have no idea how to delete the objects that are older then 2 days.
Any help would be highly appreciated.
Thanks in advance!