Skip to content

Instantly share code, notes, and snippets.

@advantis
advantis / ADVManagedCollectionUpdater.h
Created June 28, 2013 07:37
Generic NSFetchedResultsControllerDelegate implementations
//
// Copyright © 2013 Yuri Kotov
//
#import <CoreData/CoreData.h>
@interface ADVManagedCollectionUpdater : NSObject <NSFetchedResultsControllerDelegate>
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@advantis
advantis / ADVKeyedSubscripting.h
Last active December 19, 2015 02:28
Generic UITableView/UICollectionView data source for Core Data
//
// Copyright © 2013 Yuri Kotov
//
#import <Foundation/Foundation.h>
@protocol ADVKeyedSubscripting <NSObject>
- (id) objectForKeyedSubscript:(id)key;
@end
@advantis
advantis / ADVResonsibilityChainProxy.h
Last active December 19, 2015 02:28
Proxy that emulates Responsibility Chain pattern
//
// Copyright © 2013 Yuri Kotov
//
#import <Foundation/Foundation.h>
@interface ADVResonsibilityChainProxy : NSObject
- (id) initWithHandlers:(NSArray *)hanlders;
@advantis
advantis / gist:5803013
Created June 18, 2013 06:13
LLDB shortcuts for `-[UIView recursiveDescription]` and `-[UIView _autolayoutTrace]`
command regex prd 's/(.+)/expression -o -- [%1 recursiveDescription]/'
command regex alt 's/(.+)/expression -o -- [%1 _autolayoutTrace]/'
@advantis
advantis / NSObject+ADVDynamicMethodOverride.h
Last active December 18, 2015 13:09
Playing around dynamic metod replacement on per-instance basis (think Decorator using runtime)
//
// Copyright © 2013 Advantis
//
#import <Foundation/Foundation.h>
// typedef id(^ADVMethodImp)(id super, ...);
@interface NSObject (ADVDynamicMethodOverride)
@advantis
advantis / gist:5787523
Created June 15, 2013 09:24
String constant macro
#define ADVConstant(_NAME_) static NSString * const _NAME_ = @#_NAME_
@advantis
advantis / ADVKeyboardManager.h
Created June 14, 2013 09:45
Automatically avoid keyboard overlapping
//
// Copyright © 2012 Yuri Kotov
//
#import <Foundation/Foundation.h>
@interface ADVKeyboardManager : NSObject
@end
@advantis
advantis / UIImage+ADVImageResizing.h
Created June 12, 2013 14:08
Creating casual resizable image
//
// Copyright © 2013 Yuri Kotov
//
#import <UIKit/UIKit.h>
@interface UIImage (ADVImageResizing)
- (UIImage *) resizableImage;
@advantis
advantis / ADVFileSharer.h
Created June 10, 2013 07:52
Reusable wrapper for UIDocumentInteractionController's "Open In" menu
//
// Copyright © 2013 Yuri Kotov
//
#import <Foundation/Foundation.h>
@interface ADVFileSharer : NSObject
- (instancetype) initWithFileURL:(NSURL *)url;
- (BOOL) presentShareMenuFromBarButtonItem:(UIBarButtonItem *)item completion:(void(^)())completion;
@advantis
advantis / UIStoryboard+ADVDeviceModifierSupport.m
Created June 5, 2013 11:43
Fix for UIStoryboard unable to recognize device-specific resource names
//
// Copyright © 2013 Yuri Kotov
//
#import <objc/runtime.h>
NS_INLINE NSString * DeviceSpecificSuffix(UIUserInterfaceIdiom idiom)
{
switch (idiom)
{