Mattt Thompson mattt

View BCP47LanguageCodeForString.m
1 2 3 4 5 6 7 8 9 10
static NSString * BCP47LanguageCodeFromISO681LanguageCode(NSString *ISO681LanguageCode) {
if ([ISO681LanguageCode isEqualToString:@"ar"]) {
return @"ar-SA";
} else if ([ISO681LanguageCode hasPrefix:@"cs"]) {
return @"cs-CZ";
} else if ([ISO681LanguageCode hasPrefix:@"da"]) {
return @"da-DK";
} else if ([ISO681LanguageCode hasPrefix:@"de"]) {
return @"de-DE";
} else if ([ISO681LanguageCode hasPrefix:@"el"]) {
View multipeer-connectivity-revisited.md

A number of tech news outlets, including WIRED, GigaOm, and MIT Technology Review, have recently started writing about Multipeer Connectivity ("one weird trick that the NSA hates"). Since the NSHipster article on the subject has been linked to in a lot of this coverage, I wanted to share some additional thoughts on the matter:

Multipeer Connectivity(http://nshipster.com/multipeer-connectivity/) represents a significant shift in the opposite direction of how we conventionally think about mobile applications. Nearly every app on your phone operates in a client-server model, with the device making requests to remote cloud services to send and receive messages, photos, and videos. The [

View UTTypeForImageData.m
1 2 3 4 5 6 7 8 9 10
@import MobileCoreServices;
 
static CFStringRef UTTypeForImageData(NSData *data) {
const unsigned char * bytes = [data bytes];
 
if (data.length >= 8) {
if (bytes[0] == 0x89 && bytes[1] == 0x50 && bytes[2] == 0x4E && bytes[3] == 0x47 && bytes[4] == 0x0D && bytes[5] == 0x0A && bytes[6] == 0x1A && bytes[7] == 0x0A) {
return kUTTypePNG;
}
}
View CustomURLCache.m
1 2 3 4 5 6 7 8 9 10
@interface CustomURLCache : NSURLCache
 
static NSString * const CustomURLCacheExpirationKey = @"CustomURLCacheExpiration";
static NSTimeInterval const CustomURLCacheExpirationInterval = 600;
 
@implementation CustomURLCache
 
+ (instancetype)standardURLCache {
static CustomURLCache *_standardURLCache = nil;
static dispatch_once_t onceToken;
View apple.html
1 2 3 4 5 6 7 8 9 10
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:d="http://www.apple.com/DTDs/DictionaryService-1.0.rng">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<d:entry id="m_en_gb0035330" d:title="apple" class="entry">
<span class="hg">
<span d:dhw="1" role="text" linebreaks="apple" class="hw">apple</span>
View keybase.md

Keybase proof

I hereby claim:

  • I am mattt on github.
  • I am mattt (https://keybase.io/mattt) on keybase.
  • I have a public key whose fingerprint is 58FC 9E3A 40F3 5F72 E402 F6C0 2755 0012 282D EB01

To claim this, I am signing this object:

View NSRange-Conventional.h
1 2 3 4 5 6 7 8 9 10
NS_INLINE NSRange NSRangeMake(NSUInteger loc, NSUInteger len) {
return NSMakeRange(loc, len);
}
 
NS_INLINE NSUInteger NSRangeMax(NSRange range) {
return NSMaxRange(range);
}
 
NS_INLINE BOOL NSRangeContainsLocation(NSUInteger loc, NSRange range) {
return NSLocationInRange(loc, range);
View Emoji.plist
1 2 3 4 5 6 7 8 9 10
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>People</key>
<array>
<string>😄</string>
<string>😃</string>
<string>😀</string>
<string>😊</string>
View NSHipster-New-Years-2014.md

Greetings, NSHipsters!

As we prepare to increment our NSDateComponents -year by 1, it's time once again for NSHipster end-of-the-year Reader Submissions! Last year, we got some mind-blowing tips and tricks. With the release of iOS 7 & Mavericks, and a year's worth of new developments in the Objective-C ecosystem, there should be a ton of new stuff to write up for this year.

Submit your favorite piece of Objective-C trivia, framework arcana, hidden Xcode feature, or anything else you think is cool, and you could have it featured in the year-end blowout article. Just comment on this gist below!

Here are a few examples of the kind of things I'd like to see:

  • Using NSStringFromSelector(@selector()) as a safer way to do KVC / KVO / NSCoding.
  • Panic's [rather surprising discovery about the internals of the Lightning Digital AV Adapter](http://www.panic.com/blog/the-lightning-di
View alfred-wwdc.url
1
alfred://customsearch/Search%20WWDC%20Sessions/wwdc/utf8/noplus/http://asciiwwdc.com/search?q={query}
Something went wrong with that request. Please try again.