This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void freeKeychainContent(void *ptr, void *info) | |
{ | |
SecKeychainItemFreeContent(NULL, ptr); | |
} | |
- (NSString *)passwordFromKeychainItem:(SecKeychainItemRef)keychainItem | |
{ | |
void *passwordData; | |
UInt32 passwordLength; | |
OSStatus status = SecKeychainItemCopyContent(keychainItem, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
int main(int argc, const char * argv[]) | |
{ | |
@autoreleasepool { | |
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; | |
NSDateFormatter *df = [[NSDateFormatter alloc] init]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *s = @"$00FF_FFFF %0001_0101"; | |
PKTokenizer *t = [PKTokenizer tokenizerWithString:s]; | |
// add support for HLA-style hex numbers like $00FF_FFFF | |
[t.numberState addPrefix:@"$" forRadix:16]; | |
[t.numberState addGroupingSeparator:'_' forRadix:16]; | |
[t setTokenizerState:t.numberState from:'$' to:'$']; | |
// add support for HLA-style binary numbers like %0001_0101 | |
[t.numberState addPrefix:@"%" forRadix:2]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma clang diagnostic push | |
#pragma clang diagnostic ignored "-Wmismatched-method-attributes" | |
- (IBAction)selectAll:(id)sender | |
{ | |
// do stuff | |
} | |
#pragma clang diagnostic pop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Taken from http://PSPDFKit.com. This snippet is under public domain. | |
#define UIKitVersionNumber_iOS_7_0 0xB57 | |
BOOL PSPDFIsUIKitFlatMode(void) { | |
static BOOL isUIKitFlatMode = NO; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
// We get the modern UIKit if system is running >= iOS 7 and we were linked with >= SDK 7. | |
if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0) { | |
isUIKitFlatMode = (NSVersionOfLinkTimeLibrary("UIKit") >> 16) >= UIKitVersionNumber_iOS_7_0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A single slash takes us back to the host's root directory, | |
// discarding any components after the path. | |
// Then make absolute so callers don't have to worry about any | |
// side-effects of working with relative URL objects. | |
return [[NSURL URLWithString:@"/" relativeToURL:url] absoluteURL]; |