Skip to content

Instantly share code, notes, and snippets.

View mmackh's full-sized avatar

Maximilian Mackh mmackh

View GitHub Profile
@mmackh
mmackh / PCCountedObjectContainer.h
Last active August 29, 2015 13:55
Ordered NSCountedSet. Subclassing and overwrite `- (id)keyForObject:(id)object` to specify your own keys for objects.
//
// PCCountedObjectContainer.h
// Slingshot
//
// Created by Maximilian Mackh on 02/02/14.
// Copyright (c) 2014 Professional Consulting & Trading GmbH. All rights reserved.
//
#import <Foundation/Foundation.h>
//
// PCMutableDirectory.h
// SmartOrderKit
//
// Created by Maximilian Mackh on 23/03/14.
// Copyright (c) 2014 Professional Consulting & Trading GmbH. All rights reserved.
//
#import <Foundation/Foundation.h>

Keybase proof

I hereby claim:

  • I am mmackh on github.
  • I am maxi (https://keybase.io/maxi) on keybase.
  • I have a public key whose fingerprint is 262F 8E5A F8AF 56AA 84BD F742 17E5 DA95 49FE 7E1B

To claim this, I am signing this object:

@mmackh
mmackh / gist:e24f4ad31326e54a68f1
Created September 21, 2014 18:20
Change UIStatusBar Color
NSString *statusBarString = [NSString stringWithFormat:@"_s%@at%@sBar",@"t",@"u"];
NSString *colorKey = @"foregroundColor";
id statusBar = [application valueForKey:statusBarString];
if (statusBar && [statusBar respondsToSelector:NSSelectorFromString(colorKey)])
{
[statusBar setValue:[AFPConstantsColorGold colorWithAlphaComponent:0.5] forKey:colorKey];
}
@mmackh
mmackh / gist:5797253
Last active December 18, 2015 14:28
Parse terrible news.ycombinator.com HTML in Obj-C with Hpple
- (void)loadCommentsOnStoryWithID:(NSString *)storyID result:(void(^)(NSArray *results))completionBlock
{
NSString *queryURLString = [NSString stringWithFormat:@"https://news.ycombinator.com/item?id=%@",storyID];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:queryURLString] cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:10];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject)
{
NSMutableArray *comments = [NSMutableArray new];
@mmackh
mmackh / NSDate+Extensions.m
Last active December 19, 2015 15:39
Find the number of overlapping days of 4 NSDates
- (BOOL) isBetweenBeginDate:(NSDate *)beginDate endDate:(NSDate *)endDate
{
return ([self compare:beginDate] == NSOrderedDescending || [self compare:beginDate] == NSOrderedSame) && ([self compare:endDate] == NSOrderedAscending);
}
- (NSInteger)distanceInDaysToDate:(NSDate *)anotherDate
{
NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [gregorianCalendar components:NSDayCalendarUnit fromDate:self toDate:anotherDate options:0];
return components.day;
@mmackh
mmackh / NSObject+Notifications.h
Last active December 23, 2015 09:39
NSObject category for an NSNotificationCenter abstraction to keep your code clean & lean.
//
// NSObject+Notifications.h
// InstaPDF
//
// Created by Maximilian Mackh on 18/09/13.
// Copyright (c) 2013 mackh ag. All rights reserved.
//
#import <Foundation/Foundation.h>
@mmackh
mmackh / NSString+Additions.h
Last active January 19, 2017 23:12
Personal NSString Additions
//
// NSString+Hash.h
// Orbitink
//
// Created by mmackh on 5/3/13.
// Copyright (c) 2013 Professional Consulting & Trading GmbH. All rights reserved.
//
#import <Foundation/Foundation.h>
@mmackh
mmackh / PCWebView.h
Last active April 13, 2017 09:48
PCWebView
//
// PCWebView.h
//
// Created by Maximilian Mackh on 25/03/2017.
// Note this Open Source class relies on PCSplitView.h found on Github
#import <UIKit/UIKit.h>
@interface PCWebView : UIView
@mmackh
mmackh / delegate.m
Last active October 29, 2019 14:39
Catalyst - NSToolbar Search
static NSString * toolbarIdentifierSearch = @"Search";
@interface IPDFToolbarItem : NSToolbarItem
@property (atomic,readwrite) id view;
@property CGSize minSize;
@property CGSize maxSize;
@end