Hi,
I have set up the application with 2 entity, called Category1 and category2. There is a to-many relationship between category1 and category2. When a cell is pushed in tableview (category1), a new tableview will display all category2 cells related to category1. Here is what an example:
I have two category1 items in the first tableview, called Food and Snacks. Item "Food" have a subcategory (category 2) that contains 5 different kinds of food. Item "Snacks" have a subcateogry (category2) that contains 10 different snacks.
So when i push the food item (category1) I just want the food item to be loaded (5 of them). Right now, I can see all 5 of the food item in the tableView, plus the 10 items from the "snacks" category2.
I use this code in category2:
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Folder" inManagedObjectContext: tag.managedObjectContext];
[request setEntity:entity];
//NSMutableSet *filtered = [tag mutableSetValueForKey:@"folders"];
// Order the events by creation date, most recent first.
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"creationDate" ascending:NO];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
[request setSortDescriptors:sortDescriptors];
[sortDescriptor release];
[sortDescriptors release];
// Execute the fetch -- create a mutable copy of the result.
NSError *error = nil;
NSMutableArray *mutableFetchResults = [[tag.managedObjectContext executeFetchRequest:request error:&error] mutableCopy];
if (mutableFetchResults == nil)
{
// Handle the error.
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
exit(-1); // Fail
}
// Set self's events array to the mutable array, then clean up.
[self setTagsArray:mutableFetchResults];
[mutableFetchResults release];
[request release];
need help !
thanks in advance!