Permalink
Browse files

[Issue #4] Adding snippets by @alistra

Signed-off-by: Mattt Thompson <m@mattt.me>
  • Loading branch information...
1 parent 585e025 commit 7d85b056722a175879a8457ad87d92267e1daf61 Aleksander Balicki committed with mattt Jan 26, 2013
Showing with 66 additions and 0 deletions.
  1. +8 −0 documents.m
  2. +8 −0 library.m
  3. +36 −0 mailcomp.m
  4. +14 −0 uuid.m
View
@@ -0,0 +1,8 @@
+// Documents Directory Path
+//
+// Platform: All
+// Language: Objective-C
+// Completion Scope: Function or Method
+
+NSArray *documentsSearchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+NSString *documentsDirectory = [documentsSearchPaths count] == 0 ? nil : [documentsSearchPaths objectAtIndex:0];
View
@@ -0,0 +1,8 @@
+// Library Directory Path
+//
+// Platform: All
+// Language: Objective-C
+// Completion Scope: Function or Method
+
+NSArray *librarySearchPaths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
+NSString *libraryDirectory = [librarySearchPaths count] == 0 ? nil : [librarySearchPaths objectAtIndex:0];
View
@@ -0,0 +1,36 @@
+// MFMailComposeViewController Initialization & Delegate
+// Methods required to use the iOS Mail Composer
+//
+// Platform: iOS
+// Language: Objective-C
+// Completion Scope: Class Implementation
+
+#import <MessageUI/MessageUI.h>
+
+- (void)presentModalMailComposerViewController {
+ if ([MFMailComposeViewController canSendMail]) {
+ MFMailComposeViewController *composeViewController = [[MFMailComposeViewController alloc] init];
+ composeViewController.mailComposeDelegate = self;
+
+ [composeViewController setSubject:<#Subject#>];
+ [composeViewController setMessageBody:<#Body#> isHTML:YES];
+ [composeViewController setToRecipients:@[<#Recipients#>]];
+
+ [self presentModalViewController:composeViewController animated:YES];
+ } else {
+ [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", nil) message:NSLocalizedString(@"<#Cannot Send Mail Message#>", nil) delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", nil) otherButtonTitles:nil] show];
+ }
+}
+
+#pragma mark - MFMailComposeViewControllerDelegate
+
+- (void)mailComposeController:(MFMailComposeViewController *)controller
+ didFinishWithResult:(MFMailComposeResult)result
+ error:(NSError *)error
+{
+ if (error) {
+ <#Handle error#>
+ }
+
+ [self dismissModalViewControllerAnimated:YES];
+}
View
14 uuid.m
@@ -0,0 +1,14 @@
+// UUID Generation Method
+// Since using the device ID is deprecated, the new recommended method of creating UUIDS
+//
+// Platform: All
+// Language: Objective-C
+// Completion Scope: Class Implementation
+
++ (NSString *)UUID {
+ CFUUIDRef UUID = CFUUIDCreate(NULL);
+ NSString *UUIDString = (__bridge_transfer NSString *)CFUUIDCreateString(NULL, UUID);
+ CFRelease(UUID);
+
+ return UUIDString;
+}

0 comments on commit 7d85b05

Please sign in to comment.