Skip to content

Instantly share code, notes, and snippets.

View odrobnik's full-sized avatar

Oliver Drobnik odrobnik

View GitHub Profile
@odrobnik
odrobnik / gist:3778230
Created September 24, 2012 20:39
Dynamically Replacing the super class
//
// DTTextSelectionRect.m
// DTRichTextEditor
//
// Created by Oliver Drobnik on 9/11/12.
// Copyright (c) 2012 Cocoanetics. All rights reserved.
//
#import <objc/runtime.h>
//
// DTTextSelectionRect.h
// DTRichTextEditor
//
// Created by Oliver Drobnik on 9/11/12.
// Copyright (c) 2012 Cocoanetics. All rights reserved.
//
#import <UIKit/UIKit.h>
@odrobnik
odrobnik / gist:3788876
Created September 26, 2012 16:02
Info Plist declaring a main bundle extension
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
@odrobnik
odrobnik / gist:3796352
Created September 27, 2012 20:42
info.plist, no extra file format chooser
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
@odrobnik
odrobnik / gist:3811844
Created October 1, 2012 13:37
Modally presenting a sheet/panel the UIKit style
//
// NSWindow+DTViewControllerPresenting.m
// DTFoundation
//
// Created by Oliver Drobnik on 10/1/12.
// Copyright (c) 2012 Cocoanetics. All rights reserved.
//
#import "objc/runtime.h"
#pragma mark - Undo Support
- (void)addUndoObservers
{
for (CatalogPage *onePage in _catalog.pages)
{
NSArray *undoableHotZoneKeys = [CatalogPageHotZone undoableKeys];
for (CatalogPageHotZone *oneHotZone in onePage.hotZones)
{
@odrobnik
odrobnik / gist:4060573
Created November 12, 2012 17:09
Comparing URLs
NSURL *a = [NSURL URLWithString:@"http://google.com/oliver.html"];
NSURL *b = [NSURL URLWithString:@"oliver.html" relativeToURL:[NSURL URLWithString:@"http://google.com"]];
if([a isEqual:b]) {
NSLog(@"Same"); // Not run
}
if([[a absoluteURL] isEqual:[b absoluteURL]]) {
NSLog(@"Same"); // Still not run
}
@odrobnik
odrobnik / gist:4086204
Created November 16, 2012 10:20
Forwarding keydown event to a search field
- (void)goToProductListWithEvent:(NSEvent *)event
{
self.selectedViewController = _productListViewController;
// make the search bar first responder
NSWindow *window = self.view.window;
[window makeFirstResponder:_productListViewController.searchField];
// set the keyDown character into the search field
_productListViewController.searchField.stringValue = [event characters];
@odrobnik
odrobnik / gist:4181256
Created December 1, 2012 09:20
Tweetbot re-auth bug
Bug Report: Tweetbot fails to sign in for retweet from other account after restore from iCloud
Steps to Reproduce:
1) Have Tweetbot set up for multiple Twitter accounts
2) backup to iCloud
3) reset device and restore from iCloud
4) open Tweetbot, when prompted re-authorize first account
5) in timeline of first account retweet something via the second account
6) Tweetbot wants to re-authorize the second account
Pod::Spec.new do |spec|
spec.name = 'DTFoundation'
spec.version = '1.0.0'
spec.summary = "Standard toolset classes and categories."
spec.homepage = "https://github.com/Cocoanetics/DTFoundation"
spec.author = { "Oliver Drobnik" => "oliver@drobnik.com" }
spec.source = { :git => "https://github.com/Cocoanetics/DTFoundation.git", :tag => spec.version.to_s }
spec.license = 'BSD'
spec.requires_arc = true