Skip to content

Instantly share code, notes, and snippets.

View myell0w's full-sized avatar
🙌

Matthias Tretter myell0w

🙌
View GitHub Profile
//
// LCKConcurrentOperation.m
// LCKOperations
//
// Created by Twig on 12/19/13.
// Copyright (c) 2013 Lickability. All rights reserved.
//
#import "LCKConcurrentOperation.h"
@cocoaNib
cocoaNib / EssentialXcodeShortcuts
Last active November 28, 2016 10:52
Essential Xcode Shortcuts
Essential Xcode Shortcuts
🇺🇸 Keyboard
⌘ B Build
⌘ R Run
⌘ U Run Test
⇧ ⌘ K Clean
⌥ ⇧ ⌘ K Clean Build Folder
⇧ ⌘ O Open quickly
@soffes
soffes / BaseTextStorage.swift
Last active July 1, 2023 10:14
Fast, concrete text storage intended to be subclassed.
import UIKit
/// Fast, concrete text storage intended to be subclassed.
class BaseTextStorage: NSTextStorage {
// MARK: - Properties
private let storage = NSMutableAttributedString()
// MARK: - NSTextStorage
@macguru
macguru / MXSEventTrackingWindow.h
Created September 2, 2016 10:47
Tell if a user interaction is currently happening though a touch event in a view's window or something else – like an external keyboard or interaction in a different window (keyboard window). Example use: check if selection change was through touch or external keyboard.
//
// MXSEventTrackingWindow.h
//
// Created by Max Seelemann on 01.09.16.
// Copyright © 2016 The Soulmen. All rights reserved.
//
/*!
@abstract Special window class used for advanced event processing.
*/
@kean
kean / cd_progressive_migration.m
Last active June 19, 2016 09:42
Tricking Core Data Into Performing Progressive Migrations
+ (BOOL)migrateStoreAtURL:(NSURL *)storeURL
models:(NSArray<NSManagedObjectModel *> *)moms // @[ mom_v1, mom_v2, mom_v3 ... ];
error:(NSError **)error {
// Find an index of the current store's mom
NSDictionary *meta = [NSPersistentStoreCoordinator metadataForPersistentStoreOfType:NSSQLiteStoreType URL:storeURL error:error];
if (!meta) {
return NO;
}
NSInteger idx = [moms indexOfObjectPassingTest:^BOOL(NSManagedObjectModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
return [obj isConfiguration:nil compatibleWithStoreMetadata:meta];
@timonus
timonus / UIWindow+AppSwitchScrollStopper.h
Last active January 6, 2017 19:01
AppSwitchScrollStopper
// UIWindow+AppSwitchScrollStopper.h
// Created by Tim Johnsen on 3/27/16.
#import <UIKit/UIKit.h>
@interface UIWindow (AppSwitchScrollStopper)
/// Call this early on in your app's lifecycle to avoid
/// scroll-related flashing when your app resumes from the background
- (void)installAppSwitchScrollStopper;
//some time, frc section may be need section offset
@objc public protocol MFetchedResultsControllerOffsetSectionDelegate{
func offsetSection() -> Int
}
class MFetchedResultsController: NSFetchedResultsController, NSFetchedResultsControllerDelegate {
weak var viewController: UIViewController? //UITableViewController UICollectionViewController
weak var scrollView: UIScrollView? //TableView CollectionView
weak var offsetSectionDelegate: MFetchedResultsControllerOffsetSectionDelegate?
@bjhomer
bjhomer / .gitconfig
Created March 13, 2015 18:15
A git alias to delete branches whose remote tracking branches are gone
# Drop this into your ~/.gitconfig
[alias]
delete-merged = !bash -c '\
REMOTE=$1 && \
REMOTE=${REMOTE:="origin"} && \
echo "Fetching $REMOTE" && \
git fetch $REMOTE --prune && \
git branch -vv | grep "gone]" | awk \"{ print \\$1 }\" | xargs git branch -d' -
@zwaldowski
zwaldowski / UIFontDescriptor+DynamicType.m
Created November 9, 2014 22:06
Dynamic Type with Weight-Matching
@implementation UIFontDescriptor (DZWDynamicType)
+ (instancetype)dzw_preferredFontDescriptorWithTextStyle:(NSString *)style {
return [[self preferredFontDescriptorWithTextStyle:style] dzw_fontDescriptorWithMatchingFamily:@"Avenir Next"];
}
- (instancetype)dzw_fontDescriptorWithMatchingFamily:(NSString *)family {
NSMutableDictionary *attributes = [self.fontAttributes mutableCopy];
[attributes removeObjectForKey:UIFontDescriptorTextStyleAttribute];
UIFontDescriptor *newDesc = (__bridge_transfer UIFontDescriptor *)CTFontDescriptorCreateCopyWithFamily((__bridge CTFontDescriptorRef)self, (__bridge CFStringRef)family);
@Kapeli
Kapeli / NSCrapField.m
Last active March 9, 2020 18:57
Yosemite NSSearchField Fixes
// 1. Disable centered look & animation:
// 1.1. Subclass NSSearchFieldCell and add:
- (BOOL)isCenteredLook
{
return NO;
}
// 1.2. Subclass NSSearchField and add: