Snippet: Finding the Current First Responder

In iOS there is no simple call to retrieve the current first responder (without resorting to private APIs). A google search turns up lots of methods that involving walking the view hierarchy, but I really like this simple, efficient method by Jakob Egger posted as an answer to this question on stack overflow.

#import "UIResponder+FirstResponder.h"

static __weak id currentFirstResponder;

@implementation UIResponder (FirstResponder)

+(id)currentFirstResponder {
    currentFirstResponder = nil;
    [[UIApplication sharedApplication] sendAction:@selector(findFirstResponder:) to:nil from:nil forEvent:nil];
    return currentFirstResponder;
}

-(void)findFirstResponder:(id)sender {
   currentFirstResponder = self;
}

@end

I don’t normally repost code from stack overflow, but the google incantations necessary to find this are non-obvious.


Posted in Code Snippets | Leave a comment

iOS Support Matrix

iOS Versions Supported by Device and Other Goodies.

iOS Versions Supported by Device and Other Goodies.


I had been meaning, for quite some time, to create a spreadsheet or graphic cross-referencing the various iOS devices and the OS version they support. By sheer happenstance, the other day, I discovered the iOS Support Matrix (see www.iosupportmatrix.com). They have created a great info-graphic that summarizes this and a bunch of other information at a glance. The graphic is free to download and available in a variety of sizes and formats.


Posted in Tips | Leave a comment

Precompiled FLAC Library for iOS


Continuing the series of precompiled audio compression libraries, tonight’s library is the Free Lossless Audio Codec. I compiled version 1.2.1 and am making the binaries available on GitHub. As soon as I get a spare moment I will document the process of compiling the library.

Compilation

The library was compiled using Xcode 4.6.1 for the armv7, armv7s and i386 architectures.

Packaging

The pseudo-framework FLAC.framework includes libFLAC.a and its header file. The library libFLAC++.a was omitted.

Testing

The decoder was tested on the iPhone simulator, running iOS 6.1, and on an iPhone 5, running iOS 6.0.1. The tests confirmed successful decoding; performance tests were not done.

The encoder has not been tested as yet.

Download

The pseudo-framework may be obtained from GitHub: IDZPrecompiledFLAC


Posted in Precompiled | 2 Comments