Skip to content

Instantly share code, notes, and snippets.

View DanielKrofchick's full-sized avatar

Daniel Krofchick DanielKrofchick

View GitHub Profile
@iwasrobbed
iwasrobbed / gist:5528897
Last active June 5, 2020 20:34
UICollectionView w/ NSFetchedResultsController & NSBlockOperation. Idea originated from Blake Watters (https://github.com/AshFurrow/UICollectionView-NSFetchedResultsController/issues/13)
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller
{
self.shouldReloadCollectionView = NO;
self.blockOperation = [[NSBlockOperation alloc] init];
}
- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id<NSFetchedResultsSectionInfo>)sectionInfo
atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type
{
__weak UICollectionView *collectionView = self.collectionView;
@Tricertops
Tricertops / gist:5483361
Created April 29, 2013 17:49
Helper functions to round screen coordinates and dimensions to screen scale.
CGFloat CGFloatAdjustToScreenScale(CGFloat value, NSRoundingMode mode) {
CGFloat (*roundingFunction)(CGFloat);
switch (mode) {
case NSRoundPlain: roundingFunction = &roundf; break;
case NSRoundUp: roundingFunction = &ceilf; break;
case NSRoundDown: roundingFunction = &floorf; break;
case NSRoundBankers:roundingFunction = &roundf; break;
}
CGFloat scale = [[UIScreen mainScreen] scale];
CGFloat result = roundingFunction(value * scale) / scale;
@sfider
sfider / LOOProfiling.h
Created July 8, 2012 18:16
Objective-C macro for measuring execution time of block of code.
//
// LOOProfiling.h
//
// Created by Marcin Swiderski on 4/12/12.
// Copyright (c) 2012 Marcin Swiderski. All rights reserved.
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
@zoul
zoul / DownloadOperation.h
Created September 14, 2010 06:36
Asynchronous NSURLConnection in concurrent NSOperation
@interface DownloadOperation : NSOperation
{
NSURLRequest *request;
NSURLConnection *connection;
NSMutableData *receivedData;
}
@property(readonly) BOOL isExecuting;
@property(readonly) BOOL isFinished;