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
typealias verFunc = @convention(c) ()->UnsafePointer<CChar> | |
let libz = dlopen("libz.dylib", RTLD_LAZY) | |
let ret = dlsym(libz, "zlibVersion") | |
let zLibVersion = unsafeBitCast(ret, verFunc.self) | |
print("\(String.fromCString(zLibVersion())!)") |
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 *)makeNewUUIDString { | |
CFUUIDRef uuid = CFUUIDCreate(NULL); | |
CFStringRef string = CFUUIDCreateString(NULL, uuid); | |
CFRelease(uuid); | |
return (__bridge_transfer NSString *)(string); | |
} |
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
@synthesize firstName = _firstName; | |
@synthesize txtFirstName = _txtFirstName; | |
[RACAbleSelf(self.firstName) subscribeNext:^(id x) { [self firstNameChanged:x]; }]; | |
[self rac_bind:RAC_KEYPATH_SELF(self.firstName) to:self.txtFirstName.rac_textSubscribable]; | |
- (void) firstNameChanged:(id)firstName { | |
NSLog(@"changed: %@", firstName); | |
} |
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
// | |
// UIGestureRecognizer+Closures.swift | |
// Closures | |
// | |
// Created by Hector on 7/23/14. | |
// Copyright (c) 2014 Hector Matos. All rights reserved. | |
// | |
import Foundation |
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
static NSInteger NSJSONReadingFuckNSNulls = (1UL << 3); | |
@implementation NSJSONSerialization (FuckNulls) | |
+ (void)load { | |
Method originalMethod = class_getClassMethod(self, @selector(JSONObjectWithData:options:error:)); | |
IMP swizzledImplementation = imp_implementationWithBlock([^id (id _self, NSData *_data, NSJSONReadingOptions _opt, NSError **_error){ | |
NSInputStream *stream = [NSInputStream inputStreamWithData:_data]; | |
[stream open]; | |
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 *)tableView:(UITableView *)tableView titleForSwipeAccessoryButtonForRowAtIndexPath:(NSIndexPath *)indexPath { | |
return @"More"; | |
} | |
- (void)tableView:(UITableView *)tableView swipeAccessoryButtonPushedForRowAtIndexPath:(NSIndexPath *)indexPath { | |
NSLog(@"I wanted to be a pretty public API, but then time ran out and they forgot me..."); | |
// Hide the More/Delete menu. | |
[self setEditing:NO animated:YES]; | |
} |
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
// Variables just contain an integer. We can have a maximum of `Int.max` variables in our program. ¯\_(ツ)_/¯ | |
private struct Var { | |
static var freshVarIx = 0 | |
let ix: Int | |
init() { | |
Var.freshVarIx+=1 | |
ix = Var.freshVarIx | |
} | |
} |
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
// | |
// Created by Cédric Luthi on 2012-02-24. | |
// Copyright (c) 2012 Cédric Luthi. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface NSData (Base64) | |
+ (id) dataWithBase64Encoding_xcd:(NSString *)base64String; |
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
static Boolean PSPDFCaseInsensitiveEqualCallback(const void *a, const void *b) { | |
id objA = (__bridge id)a, objB = (__bridge id)b; | |
Boolean ret = FALSE; | |
if ([objA isKindOfClass:NSString.class] && [objB isKindOfClass:NSString.class]) { | |
ret = ([objA compare:objB options:NSCaseInsensitiveSearch|NSLiteralSearch] == NSOrderedSame); | |
}else { | |
ret = [objA isEqual:objB]; | |
} | |
return ret; | |
} |
OlderNewer