Skip to content

Instantly share code, notes, and snippets.

View NorrinRadd's full-sized avatar

Brandon Trussell NorrinRadd

View GitHub Profile
@NorrinRadd
NorrinRadd / gist:481c2815b7435c66a5c6
Created June 16, 2014 16:35
find class name in swift
func PrintableClassName<T>(variable : T) -> String
{
// Test for ObjC
if let v = variable as? NSObject
{
return v.classForCoder.description()
}
// If the object *can* be converted to ObjC type, do so
// However you lose any specifics as to type
@NorrinRadd
NorrinRadd / gist:f6073fc721224d69bc9f
Created June 12, 2014 14:06
Swift functions on all types
extension T! {
typealias ObjectiveCType = AnyObject
static func getObjectiveCType() -> Any.Type
func bridgeToObjectiveC() -> AnyObject
static func bridgeFromObjectiveC(x: AnyObject) -> T!?
static func isBridgedToObjectiveC() -> Bool
}
@NorrinRadd
NorrinRadd / SlideKeyboard.m
Created February 11, 2014 19:03
slide keyboard in from the right. Looks for UITextEffectsWindow in jacky way.
[[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillShowNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note)
{
NSLog(@"Windows: %@", [UIApplication sharedApplication].windows);
for (UIWindow *window in [UIApplication sharedApplication].windows)
{
if ([window.class.description rangeOfString:@"Text"].location != NSNotFound)
{
window.alpha = 0.0f;