Skip to content

Instantly share code, notes, and snippets.

@jeremytregunna
Forked from carsonmcdonald/EmailShareType.m
Created October 3, 2012 02:56
Show Gist options
  • Save jeremytregunna/3824687 to your computer and use it in GitHub Desktop.
Save jeremytregunna/3824687 to your computer and use it in GitHub Desktop.
Delegate ARC
#import "EmailShareType.h"
@implementation EmailShareType
{
UIViewController *pvController;
MFMailComposeViewController *mailComposeController;
}
- (void)share:(UIViewController *)parentViewController
{
pvController = parentViewController;
mailComposeController = [[MFMailComposeViewController alloc] init];
mailComposeController.mailComposeDelegate = self;
[mailComposeController setSubject:@"Title"];
[mailComposeController setMessageBody:@"Message" isHTML:YES];
[parentViewController presentModalViewController:mailComposeController animated:YES];
}
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
[pvController dismissModalViewControllerAnimated:YES];
if(self.completionHandler)
{
self.completionHandler();
}
}
@end
#import "ViewController.h"
#import "EmailShareType.h"
@interface ViewController ()
@end
@implementation ViewController
- (IBAction)emailAction:(id)sender
{
EmailShareType *email = [[EmailShareType alloc] init];
[email share:self];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment