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 […]

How to install EPEL and apachetop on Centos 5 and Centos 6

I wanted to use apachetop to monitor one of my servers in real time. Much like top, apachetop reads the acces_log file in /var/logs/httpd/ and displays the results as apache processes happen.

Rather than installing apachetop from source, I thought a simple command like

yum install apachetop

should to the trick… but it doesn’t work by default. Now what?

Well an install via yum will only work if it is configured to look in the right repositories. Apachetop however is not part of the standard repos, hence we need to add what’s known as the EPEL package to yum (it stands for Extra Packages for Enterprise Linux).

In this article I’ll show you how to do it and how to run apachetop.

Read more

How to test the state of a UISwitch

We can use the isOn property of your switch to do this: if (flickSwitch isOn) { statusLabel.text = @”The Switch is ON”; } else { statusLabel.text = @”The Switch is OFF”; } Alternatively we can use the square-bracket notation like so: if ([flickSwitch.isOn]) { statusLabel.text = @”The Switch is ON”; } else { statusLabel.text = […]

Welcome to my iOS Dev Diary

I wanted to write apps for iOS ever since I bought my first iPad. In fact I’ve quickly invested into a MacBook Pro in June 2011 just so that I could do it. That is now exactly one year ago. I’ve managed to put my “Hello World” app together and expanded several other options to […]