Month: March 2015

Capturing Text from Dictation in iOS

Capturing Text from Dictation in iOS

Users of your app can tap that little microphone key on the left side of the keyboard to speak what they would normally type in. A handy feature for users, but difficult to track in your application. While the UITextView or UITextField text property gets populated, it doesn’t call the standard delegates such as shouldChangeCharactersInRange.

How to capture the text from a UITextField:

Add this to your awakeFromNib or viewDidload method

[self.textField addTarget: self
action: @selector(eventEditingChanged:)
forControlEvents: UIControlEventEditingChanged];

The implementation of the eventEditingChanged method

-(void)eventEditingChanged:(UITextField *)sender {

if (sender.text.length <= 0) {

UITextInputMode *inputMode = sender.textInputMode;
NSString *modeIdentifier = [inputMode respondsToSelector:@selector(identifier)] ? (NSString *)[inputMode performSelector:@selector(identifier)] : nil;

if([modeIdentifier isEqualToString:@"dictation"])
//do something with sender.text

How to capture the text from a UITextView:

Add this to your awakeFromNib or viewDidLoad method

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(modeChange:) name:UITextInputCurrentInputModeDidChangeNotification object:nil];

The implementation of the modeChange method

-(void)modeChange:(NSNotification *)notification
NSString *inputMethod = self.textView.textInputMode.primaryLanguage;

if (inputMethod != nil) {
if (![inputMethod isEqualToString:@"dictation"]) {
//do something with self.textView.text

And finally remove the observer

- (void) dealloc
[[NSNotificationCenter defaultCenter] removeObserver:self];

Now your users will not be stifled from their laziness of not typing. Enjoy capturing that dictated text.

Implementing Base 36 in your iOS App

Implementing Base 36 in your iOS App

Base 36 can be a great way to represent a number with up to 8 alpha numeric characters. If you have an auto number and don’t want to represent it with just a number, you can convert it Base 36 to make it look a little sexier. Wikipedia has a great overview of the technology Base 36.

To convert a number to Base 36 you can use this c based algorithm

static char *base36enc(long unsigned int value)
	char base36[37] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	/* log(2**64) / log(36) = 12.38 => max 13 char + '\0' */
	char buffer[14];
	unsigned int offset = sizeof(buffer);
	buffer[--offset] = '\0';
	do {
		buffer[--offset] = base36[value % 36];
	} while (value /= 36);
	return strdup(&buffer[offset]);

Calling this from Objective-C and get the string value

char *wo = base36enc(someint)
NSString *stringValue = [NSString stringWithUTF8String:wo];

There you go. Pretty simple to use in your Objective-C app.

The Podcasts I Roll With

The Podcasts I Roll With


My semi-daily commute to downtown Denver is usually occupied by sports talk radio, although I do love to listen to a few different podcasts each week. I thought I would share the ones I like and get some feedback on some other podcasts I haven’t heard of as well.

I am mainly interested in iOS and mobile related podcasts. I also love Iowa State basketball so I do listen to the Cyclone Fanatic podcast.


a16z may be my favorite podcast. It’s not development related, but the interviews they hold with business and technology leaders around the bay area is always interesting.


NSBrief focuses specifically on iOS development. The interviews are mostly with independent iOS developers with each interview covering a different framework or aspect of iOS development.

Adventures in Angular

AngularJS is the javascript framework of choice when I do web development. There is usually great discussions and interviews in all of their episodes.


Weekly episodes about the hottest new apps and what’s happening with the popular apps such as Snapchat, Facebook and others.


In depth interviews with former and current Apple employees. I’ve gained a lot of insight about how things within Apple work from this podcast.

iDeveloper Podcast

They recently put out a podcast on developing an app with Swift and the challenges that came along with that.

Keeping up with these podcasts isn’t that difficult as some are not as frequent publishers as others. a16z has probably been the most consistent at 1 or 2 a week but most of the others are maybe 1 or 2 a month. If you’re a developer or technology enthusiast then I’m sure you’ll find a lot of values in these podcasts.