Skip to content

Instantly share code, notes, and snippets.

@advantis
advantis / ADVLocationDetector.h
Last active December 27, 2015 13:19
Simple location detector
//
// Copyright © 2013 Yuri Kotov
//
#import <CoreLocation/CoreLocation.h>
typedef void(^ADVLocationHandler)(CLLocation *location, NSError *error);
@interface ADVLocationDetector : NSObject
@advantis
advantis / ADVColor.h
Last active December 26, 2015 18:19
UIColor from hex without string parsing, e.g. RGB(0x4C2BFF)
//
// Copyright © 2013 Yuri Kotov
//
#import <UIKit/UIKit.h>
__attribute__((always_inline))
extern inline UIColor * RGB(int color);
//
// Copyright © 2013 Yuri Kotov
//
#import <Foundation/Foundation.h>
@interface NSCalendar (ADVCalculations)
- (NSComparisonResult) compareDate:(NSDate *)date1 toDate:(NSDate *)date2 withGranularity:(NSCalendarUnit)granularity;
- (BOOL) isDate:(NSDate *)date1 equalToDate:(NSDate *)date2 withGranularity:(NSCalendarUnit)granularity;
@advantis
advantis / gist:6988180
Created October 15, 2013 08:09
Thoughts about a bit more formal approach to indexed/keyed subscripting
@protocol ADVIndexedSubscripting <NSObject>
- (id) objectAtIndexedSubscript:(NSUInteger)index;
@end
@protocol ADVMutableIndexedSubscripting <ADVIndexedSubscripting>
- (void) setObject:(id)object atIndexedSubscript:(NSUInteger)index;
@end
@protocol ADVKeyedSubscripting <NSObject>
- (id) objectForKeyedSubscript:(id)key;
@advantis
advantis / ADVPlaceholderViewController.h
Last active December 25, 2015 13:49
View controller supporting nested storyboard loading
//
// Copyright © 2013 Yuri Kotov
//
#import <UIKit/UIKit.h>
@interface ADVPlaceholderViewController : UIViewController
@end
@advantis
advantis / UIViewController+ADVSegueDispatch.m
Last active December 23, 2015 23:49
Simple storyboard segues dispatch
//
// Copyright © 2013 Yuri Kotov
//
@implementation UIViewController (ADVSegueDispatch)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
SEL selector = NSSelectorFromString(segue.identifier);
//
// UIImage+H568.m
//
// Created by Angel Garcia on 9/28/12.
// Copyright (c) 2012 angelolloqui.com. All rights reserved.
//
#import <objc/runtime.h>
@implementation UIImage (H568)
@advantis
advantis / ADVDataSource.h
Last active December 4, 2018 11:05
Generic UITableView/UICollectionView data source for multiple sections
//
// Copyright © 2013 Yuri Kotov
//
#import <Foundation/Foundation.h>
typedef void(^ADVCellConfigurationBlock)(id cell, id object);
@interface ADVDataSource : NSObject <UITableViewDataSource, UICollectionViewDataSource>
@advantis
advantis / ADVArrayDataSource.h
Last active December 20, 2015 10:59
Generic UITableView/UICollectionView data source for objects in NSArray
//
// Copyright © 2013 Yuri Kotov
//
#import <Foundation/Foundation.h>
#import "ADVIndexedSubscripting.h"
typedef void(^ADVCellConfigurationBlock)(id cell, id object);
@interface ADVArrayDataSource : NSObject <ADVIndexedSubscripting, UITableViewDataSource, UICollectionViewDataSource>
@advantis
advantis / ADVManagedObjectController.h
Created July 29, 2013 11:10
Simple NSManagedObject update observer
//
// Copyright © 2013 Yuri Kotov
//
#import <Foundation/Foundation.h>
typedef void(^ADVManagedObjectHandler)(id object);
@interface ADVManagedObjectController : NSObject