December, 2011


14
Dec 11

iOS Find the current first responder

Quite often you need to know which control is currently the first responder, for ages i have been rolling the same solution over and over again and I thought it about time that i shared it.

Its basically a category on UIView so you can call:

[self.view findFirstResponder];

Imagine you wanted to make sure the keyboard (or any other editor view) was closed you could:

UIView *firstResponder = [self.view findFirstResponder];
[firstResponder resignFirstResponder];

The code is stupid simple:

UIView+AblebotsAdditions.h

#import 
 
@interface UIView (Ablebots)
 
- (UIView *)findFirstResponder;
 
@end

UIView+AblebotsAdditions.m

#import "UIView+AblebotsAdditions.h"
@implementation UIView (Ablebots)
 
- (UIView *)findFirstResponder
{
    if (self.isFirstResponder) {
        return self;
    }
    for (UIView *subView in self.subviews) {
        if ([subView isFirstResponder]){
            return subView;
        }
        if ([subView findFirstResponder]){
            return [subView findFirstResponder];
        }
    }
    return nil;
}
 
@end

12
Dec 11

.GitIgnore for xCode 4 projects.

xCode git support is great, but if your working in a team or on multiple machines you will want to ignore any user/machine specific files.

In my .gitinore I have:

.DS_Store
*.swp
*~.nib
build/
*.pbxuser
*.perspective
*.perspectivev3
xcuserdata/

Seems to work pretty well.


8
Dec 11

Collabable OSX Notifications

This is a small OSX application I wrote for Collabable.com


8
Dec 11

Adding Growl support to your OSX application

I recently built a small OSX utility that sits in the menu bar and polls your Collabable account for new discussions, one of the final feature i needed to implement was Growl support.

The brief was simple enough, two type of growl notification were required, a simple digest of all discussions when you first logged in and then a specific “New Discussion” notification when a new discussion came in.

Continue reading →