- (id)initWithPerson:(NSManagedObject *)aPerson
{
   if ((self = [super initWithStyle:UITableViewStylePlain])) {
      NSManagedObjectContext *moc = [aPerson managedObjectContext];
      person = [aPerson retain];

      NSFetchRequest *request = [[NSFetchRequest alloc] init];
      [request setEntity:[NSEntityDescription entityForName:@"Task" 
         inManagedObjectContext:moc]];
      [request setSortDescriptors:[NSArray arrayWithObject:
         [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]]];

      [request setPredicate:[NSPredicate predicateWithFormat:@"person == %@", person]];
      resultsController = [[NSFetchedResultsController alloc] 
                             initWithFetchRequest:request 
                             managedObjectContext:moc 
                               sectionNameKeyPath:nil 
                                        cacheName:nil];

      resultsController.delegate = self;

      [request release];

      NSError *error = nil;

      if (![resultsController performFetch:&error]) {
         NSLog(@"Błąd podczas pobierania danych: %@", error);
      }
   }
   return self;
}
