Skip to content

Category Archives: iOS

Programmatically show Mail settings in iOS

MFMailComposerViewController can’t handle a device without a mail account defined, a easy and nice way to get around it is to do like this: if ([MFMailComposeViewController canSendMail]) { MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init]; mailController.mailComposeDelegate = (id<MFMailComposeViewControllerDelegate>) self; [mailController setMessageBody:@"Test Mail" isHTML:YES]; [self presentModalViewController:mailController animated:YES]; } else { NSString *bodyText = @"Test Mail"; NSURL *url [...]

Static (Read-only) text in Settings Bundle

Since I couldn’t find this anywhere else I will write it here on my blog, to add a static (read-only) text to the Settings Bundle add this to the plist (easiest using the source code editor). <span style="font-family: monospace;">&lt;dict&gt;</span> <span style="font-family: monospace;">&lt;key&gt;Key&lt;/key&gt;</span> <span style="font-family: monospace;">&lt;string&gt;version_preference&lt;/string&gt;</span> <span style="font-family: monospace;">&lt;key&gt;Type&lt;/key&gt;</span> <span style="font-family: monospace;">&lt;string&gt;PSTitleValueSpecifier&lt;/string&gt;</span> <span style="font-family: monospace;">&lt;key&gt;DefaultValue&lt;/key&gt;</span> <span [...]

Checking if preferences exists on iOS

If you have a settings bundle in your application, this is a good way to check if you can access them, if not you can set the default values for the preferences. id testPreference = [[NSUserDefaults standardUserDefaults] objectForKey:@"sync_preference"]; if (testPreference == nil) { [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"sync_preference"]; }