Latest Articles

Use the navigation at the bottom to see older articles

How to send an email in iOS

This is tricky but doable. We’re using the MFMailComposeViewController protocol for this (don’t ask). This will open the mail app on your device. Older devices without mail sending capability will crash when you call this method so we’ll check before we do this. if ([MFMailComposeViewController canSendMail]) { MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init]; mailer.mailComposeDelegate = […]

How to exchange data between View Controllers

If you have two view controller classes you probably want to exchange data between them. Thanks to two methods we can do that, provided one view controller is presented via a modal segue. Here’s how it works step by step. Imagine you had two labels on each View Controller. We’ll call them myLabel1 and myLabel2 […]

How to add a second View Controller

Here’s how you add a new View Controller to your project and switch to it via a segue: open a new Single View project add am Objective-C class and select subclass of UIViewController (we’ll call it MyViewController here) in MyViewController.h, import the other ViewController.h and vice versa, in ViewController.h, import MyVewController.h too head over to […]

I’m trying to read out the value of…

I’m trying to read out the value of a UISlider and put it into a UIProgressView. Not a problem, all I need is to divide my UISlider.value by 100 to get the correct output. So far so good. However, for some reason this statement does not work. I don’t know why: self.progressValue.progress = [[self.mySlider.value]/100]; Doesn’t […]

How to fix “broken image captions” in WordPress 3.4

We’ve been discussing an issue with broken captions at the WordPress forum over the last few days. It appears that due to a code change in the WordPress core, captions are now inserted in a different way. This is to allow for HTML in captions which was not possible beforehand.

Turns out that many themes have not been updated to make use of this. Sadly this means that many users are left hanging with themes that are no longer compatible with the latest version of WordPress.

Lets take a look at the problem and see if we can fix it.

Read more

How to concatenate strings (i.e. print several at a time)

This is really simple in PHP, however it’s not obvious in Objective-C because you’re not printing the strings directly. Rather you print two objects that point to each string. There is a method though which has the same effect: stringByAppendingString. Here’s how you use it: self.myLabel.text = [@”This is ” stringByAppendingString: @”my label”]; It gets […]

How to check the battery level of your iOS device?

We can use the batteryLevel property of the UIDevice class for this. It will return a float: float myFloat = [[UIDevice currentDevice] batteryLevel]; If you’d like to print this in a UILabel you’ll have to convert it into a String Object like so: self.myLabel.text = [NSString stringWithFormat:@”%f”, myFloat]; For this to work battery monitoring needs […]

How to test the state of a UISegmentedControl

We can use the selectedSegmentIndex property for this. Our segmented control thingy starts at 0 for the first value: if (segmentSwitch.selectedSegmentIndex == 0 ) { segmentLabel.text = @”You’ve selected YES”; } else { segmentLabel.text = @”You’ve selected NO”; } If you want to trigger an action when someone makes a selection you can query the […]