Skip to content

Instantly share code, notes, and snippets.

View HHuckebein's full-sized avatar

Bernd Rabe HHuckebein

View GitHub Profile
@HHuckebein
HHuckebein / NSEntityDescription+Toolbox.h
Created July 7, 2012 09:54
Category on NSEntityDescription to set the correct persistent store
//
// NSEntityDescription+Toolbox.h
//
//
// Created by Rabe Bernd on 02.07.12.
// Copyright (c) 2012 RABE_IT Services. All rights reserved.
//
#import <CoreData/CoreData.h>
@HHuckebein
HHuckebein / NSDate+Toolbox.h
Last active October 7, 2015 22:58
NSDate+Toolbox
//
// NSDate+Toolbox.h
//
// Created by Rabe Bernd on 01.04.12.
// Copyright (c) 2012 RABE_IT Services. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef enum {
@HHuckebein
HHuckebein / Globals.h
Last active October 12, 2015 20:58
Provide localized content for languages not supported by iOS
//
// Globals.h
//
// Created by Rabe Bernd on 03.04.12.
// Copyright (c) 2012 RABE_IT Services. All rights reserved.
//
#ifdef __OBJC__
NSString *CustomLocalized(NSString *stringToken);
NSBundle *yourBundle(void);
@HHuckebein
HHuckebein / FSAppDelegate.m
Created April 8, 2013 07:37
iOS fast startup using gcd
//
// FSAppDelegate.m
// FastStart
//
// Created by Rabe Bernd on 28.02.12.
// Copyright (c) 2012 RABE_IT Services. All rights reserved.
//
#import "FSAppDelegate.h"
@HHuckebein
HHuckebein / AppDelegate+ImportDB.m
Created April 8, 2013 07:58
Convert SQLite database into a CoreDate model - uses Marus Zarras - ..prefix.pch add-on Bill Dudney - SQLiteAccess.m/.h
//
// AppDelegate+ImportDB.m
// LogBook
//
// Created by Bernd Rabe on 16.09.10.
// Copyright 2010 RABE_IT Services. All rights reserved.
//
// Helper
#import "NSDateFormatter+DateFromStringExtension.h"
@HHuckebein
HHuckebein / UITabBarControllerSequence.m
Created April 8, 2013 08:24
Initialize the sequence of UITabBarControllers read for userdefaults
//
//
//
//
// Created by Bernd Rabe on 07.08.12.
// Copyright (c) 2012 RABE_IT Services. All rights reserved.
//
#pragma mark - TabBarController Sequence
@HHuckebein
HHuckebein / GistCommunicationManager.h
Created June 10, 2013 09:33
A pattern for implementing a class managing a NSOperationQueue and NSOperations. The files attached show how to apply this pattern to downloading gists/gravatar images from github.com
//
// GistCommunicationManager.h
// GistExplorer
//
// Created by Bernd Rabe on 28.05.13.
// Copyright (c) 2013 RABE_IT Services. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "OperationDelegate.h"
@HHuckebein
HHuckebein / test_ManuallyTriggeredSegueIsConnected
Created August 27, 2013 06:50
Test if a manually triggered segue is connected. The convention for segue names are always follows the pattern view controller class name appended by the string "Segue".
- (void)test_ExamplesVCSegueConnected
{
STAssertNoThrow([self.sut performSegueWithIdentifier:[[self appDelegate] segueIdentifierForClass:[ExamplesVC class]] sender:self], @"ExamplesVC should be connected");
}
@HHuckebein
HHuckebein / Test_UIBarButtonItemSegue
Created August 27, 2013 06:55
Testing the infoBarButtonItem objects segue connection. Here it should be named after the string "InfoVCSegue"
- (void)test_infoBarButtonItemSegue
{
// then
UIBarButtonItem *button = [self.sut infoBarButtonItem];
SEL selector = [button action];
assertThat(NSStringFromSelector(selector), is(equalTo(@"perform:")));
id target = [button target];
assertThat(NSStringFromClass([[target class] superclass]), is(equalTo(@"UIStoryboardSegueTemplate")));
@HHuckebein
HHuckebein / MethodSwizzling
Created August 27, 2013 07:10
Helper method for method swizzling. Don't forget to import #import <objc/runtime.h>.
+ (void)swapInstanceMethodsForClass:(Class)cls selector:(SEL)sel1 andSelector:(SEL)sel2
{
Method method1 = class_getInstanceMethod(cls, sel1);
Method method2 = class_getInstanceMethod(cls, sel2);
method_exchangeImplementations(method1, method2);
}