title: MFMailComposeViewController in the delegate
body: <p>The question deals with an application which uses many views in a UINavigation controller Style.</p>
  
  <p>I have a simple function in my delegate which can be used by all views to plot-out error message</p>
  
  <p>// In Appdelegate.m</p>
  
  <pre><code>-(void)popErrorWindow:(NSString *)theError
  {
      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:theError
                                                     delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Report",nil];
      [alert show];
      [alert release];
  }
  
  
  - (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
          if (buttonIndex == 1)
          {
              NSLog(@"report");
              [self mailIt:@"error name"];
          }
      }
  </code></pre>
  
  <p>Now, wanting to have a mechanism that will email the error along with some other data I have created this:</p>
  
  <pre><code>-(void)mailIt:(NSString *)theError {
      NSLog(@"Mail it");
      pickerMail = [[MFMailComposeViewController alloc] init];
      pickerMail.mailComposeDelegate = self;
  
      [pickerMail setSubject:@"error via email"];
  
  NSMutableString *body = [NSMutableString string];
  
      [body appendString:@"Error XXX "];
  
      [pickerMail setMessageBody:body isHTML:YES];
  
  
      // Problem here:
      [self.window presentModalViewController:pickerMail animated:YES];   
  }
  
  - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
  
  {
      // Problem here:
      [self.window  dismissModalViewControllerAnimated:YES];
      //NSLog(@"mail was sent");
  }
  </code></pre>
  
  <p>The problem is in self.window , which is not the right way to access this from the delegate, 
  I still want to have the mail element in the delegate as all views can call the error alert, and I would like to have only one place for this mechanism.</p>
  
  <p>How should I do it from inside the delegate, what should replace the self.window?</p>