Skip to content

Instantly share code, notes, and snippets.

View michaelochs's full-sized avatar

Michael Ochs michaelochs

  • Cologne, Germany
View GitHub Profile
@steipete
steipete / PresentActionSheetWorkaround.mm
Last active January 27, 2020 04:32
UIKit has two places where it tries to present an action sheet on the rootViewController when it should present things on the topmost presentedViewController. This is our attempt of the least horrible workaround to fix this issue. (http://www.openradar.me/26295020).
#warning This still misses safeguards and has private API references in it. Use only when you really know what you're doing!
// pspdf_swizzleSelectorWithBlock not provided. Use your swizzling helper of choice
// (e.g. http://petersteinberger.com/blog/2014/a-story-about-swizzling-the-right-way-and-touch-forwarding/)
// Fixes rdar://26295020
static void PSPDFInstallWorkaroundForSheetPresentationIssue26295020(void) {
__block auto removeWorkaround = ^{};
const auto installWorkaround = ^{
const SEL presentSEL = @selector(presentViewController:animated:completion:);
@jspahrsummers
jspahrsummers / GHRunLoopWatchdog.h
Created January 28, 2015 20:50
A class for logging excessive blocking on the main thread
/// Observes a run loop to detect any stalling or blocking that occurs.
///
/// This class is thread-safe.
@interface GHRunLoopWatchdog : NSObject
/// Initializes the receiver to watch the specified run loop, using a default
/// stalling threshold.
- (id)initWithRunLoop:(CFRunLoopRef)runLoop;
/// Initializes the receiver to detect when the specified run loop blocks for
// Dispatch
//
// Usage:
// Async dispatch to main queue
// -->block
// Async dispatch to queue
// queue --> block
// Sync dispatch to main queue
// -->|block
// Sync dispatch to queue
@neonichu
neonichu / update_xcode_plugins
Last active September 18, 2019 14:09
Update DVTPlugInCompatibilityUUIDs for installed plugins from Xcode 5.1 beta to final
#!/bin/sh
#ID='A16FF353-8441-459E-A50C-B071F53F51B7' # Xcode 6.2
ID='992275C1-432A-4CF7-B659-D84ED6D42D3F' # Xcode 6.3
PLIST_BUDDY=/usr/libexec/PlistBuddy
function add_compatibility() {
"$PLIST_BUDDY" -c "Add DVTPlugInCompatibilityUUIDs:10 string $2" \
"$1/Contents/Info.plist"
@steipete
steipete / Macros.h
Last active January 6, 2024 07:24
Declare on your main init that all other init methods should call. It's a nice additional semantic warning. Works with Xcode 5.1 and above. Not tested with earlier variants, but should just be ignored. A reference to this macro shortly appeared in https://developer.apple.com/library/ios/releasenotes/ObjectiveC/ModernizationObjC/AdoptingModernObj…
#ifndef NS_DESIGNATED_INITIALIZER
#if __has_attribute(objc_designated_initializer)
#define NS_DESIGNATED_INITIALIZER __attribute((objc_designated_initializer))
#else
#define NS_DESIGNATED_INITIALIZER
#endif
#endif
@beccadax
beccadax / IndexSetEnumeration.m
Last active December 17, 2015 08:48
This gist includes a quick syntax for constructing NSIndexSets—[@0:9] and [@0:9 step:2]—and fast enumeration support for NSIndexSet (yielding NSNumbers). The result is that you can enumerate over ranges using for/in. The gist is CodeRunner ready.
#import <Foundation/Foundation.h>
@interface NSNumber (range)
- (NSIndexSet*):(NSUInteger)max;
- (NSIndexSet*):(NSUInteger)max step:(NSUInteger)step;
@end
@numist
numist / selector_belongsToProtocol.m
Last active April 26, 2022 07:16
Detect if a selector belongs to a protocol
/*
* Copyright © 2012 Scott Perry (http://numist.net)
*
* Released under the MIT License; its terms are at the end of this file.
*/
#import <objc/runtime.h>
/**
* `selector_belongsToProtocol` solves a common problem in proxy objects for delegates where selectors that are not part of the protocol may be unintentionally forwarded to the actual delegate.
@ashtom
ashtom / download_crashes.rb
Created December 12, 2011 18:37
Download crashes of a crash group from HockeyApp
require "rubygems"
require "json"
require "open-uri"
puts "API Token:"
api_token = gets.strip
puts "App ID:"
app_id = gets.strip