Skip to content

Instantly share code, notes, and snippets.

View robnadin's full-sized avatar

Rob Nadin robnadin

View GitHub Profile
@robnadin
robnadin / debug_ats_allow_host.sh
Created September 3, 2015 10:57
Xcode 7 run script phase to exclude a specific domain from App Transport Security via user-defined build settings
if [ "$ALLOW_INSECURE_HTTP_LOADS" = "YES" ]; then
PLIST_BUDDY="/usr/libexec/PlistBuddy"
cd "${TARGET_BUILD_DIR}"
DOMAIN_PATH=":NSAppTransportSecurity:NSExceptionDomains:${INSECURE_SERVER_HOST}"
$PLIST_BUDDY -c "Delete ${DOMAIN_PATH}" "${INFOPLIST_PATH}"
$PLIST_BUDDY -c "Add ${DOMAIN_PATH} dict" "${INFOPLIST_PATH}"
$PLIST_BUDDY -c "Add ${DOMAIN_PATH}:NSExceptionAllowsInsecureHTTPLoads bool true" "${INFOPLIST_PATH}"
fi
@robnadin
robnadin / DecimalNumberHandlerExtensions.swift
Created July 31, 2015 08:45
Extensions to the NSDecimalNumberHandler class for more Swift-like decimal number operations when using a custom decimal number behaviour
extension NSDecimalNumberHandler {
public func calculate(closure: () -> NSDecimalNumber) -> NSDecimalNumber {
let defaultBehavior = NSDecimalNumber.defaultBehavior()
NSDecimalNumber.setDefaultBehavior(self)
let result = closure()
NSDecimalNumber.setDefaultBehavior(defaultBehavior)
return result
}
}
@robnadin
robnadin / !Fetchable.swift
Last active August 29, 2015 14:26
An extendable protocol for NSManagedObject subclasses for simple data fetching
//
// Fetchable.swift
// CoreDataGenerics
//
// Created by Rob Nadin on 29/07/2015.
// Copyright © 2015 Rob Nadin. All rights reserved.
//
import CoreData
@robnadin
robnadin / DetailViewController.swift
Created February 16, 2015 00:47
Animated navigation bar tint color on push and interactive pop
//
// DetailViewController.swift
// TransitionCoordinator
//
// Created by Rob Nadin on 15/02/2015.
// Copyright (c) 2015 Rob Nadin. All rights reserved.
//
import UIKit
@robnadin
robnadin / CSStickyHeaderFlowLayout.m
Created February 12, 2015 20:08
Non-stretchable sticky header collection view flow layout
/*
* This file is part of the CSStickyHeaderFlowLayout package.
* (c) James Tang <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#import "CSStickyHeaderFlowLayout.h"
#import "CSStickyHeaderFlowLayoutAttributes.h"
@robnadin
robnadin / AView.swift
Last active August 29, 2015 14:14
How to load a UIView subclass from a nib using designated initializers in Swift
//
// AView.swift
// LoadViewFromNib
//
// Created by Rob Nadin on 27/01/2015.
// Copyright (c) 2015 Rob Nadin. All rights reserved.
//
import UIKit
@robnadin
robnadin / AutoSizingCell.swift
Created December 24, 2014 08:58
Workaround for self-sizing table view cells on iOS 8
//
// AutoSizingCell.swift
//
//
// Created by Rob Nadin on 24/12/2014.
// Copyright (c) 2014 Rob Nadin. All rights reserved.
//
import UIKit