Skip to content

Instantly share code, notes, and snippets.

View kolinkrewinkel's full-sized avatar

Kolin Krewinkel kolinkrewinkel

View GitHub Profile
@kolinkrewinkel
kolinkrewinkel / NSString+KKEmojiHandling.h
Last active December 26, 2015 02:19
NSString category for finding the composed-character length. Practical use for most locales is finding the display-length of an emoji-containing string. ✨
@interface NSString (KKEmojiHandling)
- (NSUInteger)KK_composedLength;
@end
@kolinkrewinkel
kolinkrewinkel / gist:3753301
Created September 20, 2012 00:48
Maintaining UITableView Scroll Position
NSIndexPath *zeroPath = [self.tableView.indexPathsForVisibleRows objectAtIndex:0];
STRPost *zeroPost = [self.fetchedResultsController objectAtIndexPath:zeroPath];
CGRect originalPosition = [self.tableView rectForRowAtIndexPath:zeroPath];
CGPoint oldContentOffset = self.tableView.contentOffset;
[self.managedObjectContext mergeChangesFromContextDidSaveNotification:note];
NSIndexPath *newIndexPath = [self.fetchedResultsController indexPathForObject:zeroPost];
CGRect newPosition = [self.tableView rectForRowAtIndexPath:newIndexPath];
CGFloat offsetPosition = originalPosition.origin.y - oldContentOffset.y;