Skip to content

Instantly share code, notes, and snippets.

@mralexgray
mralexgray / DataManager.h
Created October 28, 2012 04:31 — forked from NachoMan/DataManager.h
Core Data singleton manager class capable of being run from a static library
// DataManager.h
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
extern NSString * const DataManagerDidSaveNotification;
extern NSString * const DataManagerDidSaveFailedNotification;
@interface DataManager : NSObject {
}
@stevederico
stevederico / gist:5316737
Last active December 15, 2015 20:09
How to Add AFIncrementalStore to an Existing Project

How to Add AFIncrementalStore to an Existing Project

Add dependencies without Cocoapods

  • Add Core Data
  • Add Mobile Core Services
  • Add System Configuration
  • Add AFIncrementalStore
  • Add AFNetworking
  • Add InflectorKit
@Andrewjp97
Andrewjp97 / SKScene+DeterminingTouches.h
Created November 25, 2013 20:46
This Objective-C Class Category on SKScene returns a Boolean value for whether a touch occurred within a specified Boundary
//
// SKScene+DeterminingTouches.h
// Space Platypus
//
// Created by Andrew Paterson on 11/25/13.
// Copyright (c) 2013 Andrew Paterson. All rights reserved.
//
#import <SpriteKit/SpriteKit.h>
@NachoMan
NachoMan / DataManager.h
Created April 15, 2011 21:15
Core Data singleton manager class capable of being run from a static library
// DataManager.h
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
extern NSString * const DataManagerDidSaveNotification;
extern NSString * const DataManagerDidSaveFailedNotification;
@interface DataManager : NSObject {
}
struct InputStreamGenerator : Generator {
var inputStream : NSInputStream
var chunkSize : Int
init(inputStream : NSInputStream, chunkSize : Int) {
self.inputStream = inputStream
self.chunkSize = chunkSize
}
@steipete
steipete / DrawInsetBeveledRoundedRect.m
Created December 17, 2011 10:00
DrawInsetBeveledRoundedRect
void DrawInsetBeveledRoundedRect( CGContextRef context, CGRect rect, CGFloat radius, UIColor *fillColor )
{
//contract the bounds of the rectangle in to account for the stroke
CGRect drawRect = CGRectInset(rect, 1.0f, 1.0f);
//contract the height by 1 to account for the white bevel at the bottom
drawRect.size.height -= 1.0f;
//Save the current state so we don't persist anything beyond this operation
CGContextSaveGState(context);
@rnapier
rnapier / observable.swift
Last active January 27, 2018 20:45
Observable sketch
import Foundation
typealias ObserverRemover = () -> Void
/*! An observable value
An `Observable` wraps any value. If you add an observer handler, then every time the value is set, your handler will be
called with the new value. Adding an observer returns a closure that is used to remove the observer. Note that the handler
is called every time the value is set, even if this does not change the value. If you only want the handler to be called
when the value changes, see `CoalescingObservable`.
//
// NetworkIndicatorManager.swift
// Indicator
//
// Created by Curt Clifton on 5/17/16.
// Copyright © 2016 curtclifton.net. All rights reserved.
//
import Foundation
import UIKit
@irace
irace / BIWebViewDelegate.m
Created September 10, 2012 02:51
JavaScript/native bridge for iOS's UIWebView
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType {
NSString *urlString = [[request URL] absoluteString];
if ([urlString hasPrefix:@"js:"]) {
NSString *jsonString = [[[urlString componentsSeparatedByString:@"js:"] lastObject]
stringByReplacingPercentEscapes];
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSError *error;