Skip to content

Instantly share code, notes, and snippets.

View ryancoughlin's full-sized avatar

Ryan Coughlin ryancoughlin

View GitHub Profile
@hollance
hollance / YourMainDataModel.m
Created August 24, 2013 13:39
Saving an NSMutableArray to a plist file using NSKeyedArchiver and NSCoding.
// Gets the path to the app's Documents folder
- (NSString *)documentsDirectory
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
return paths[0];
}
// Gets the path to the data file
- (NSString *)dataFilePath
{
@hsjunnesson
hsjunnesson / gist:9e07291b7ccd35cea269
Created September 16, 2014 17:03
CirclePhotoView.playground
// Playground - noun: a place where people can play
import UIKit
import QuartzCore
@IBDesignable
public class CirclePhotoView: UIView {
@IBInspectable public var image: UIImage?
@Ashton-W
Ashton-W / UIStoryboardSegue+Assignable.m
Created November 13, 2014 06:08
I'm happy with this method of moving models around in segues. For every model that might move around, a protocol is created for assignment, and a segue category method is added to assign it to destination view controllers if they conform to it. `prepareForSegue:` sends a messages for all its models to any segue.
/***
*
* Usage:
* ```
* - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
* {
* [segue prepareWithExampleModel:self.model];
* }
* ```
*/
@natecook1000
natecook1000 / NSTimer+Closure.swift
Last active July 12, 2024 05:11
Scheduled NSTimer with a Swift closure
extension NSTimer {
/**
Creates and schedules a one-time `NSTimer` instance.
- Parameters:
- delay: The delay before execution.
- handler: A closure to execute after `delay`.
- Returns: The newly-created `NSTimer` instance.
*/
@raberm
raberm / GradientView.swift
Last active October 18, 2015 16:36
@IBDesignable/@IBInspectable GradientView (linear gradient, 2 stops)
// ©2015 Massimiliano Raber, MIT license
// @IBDesignable/@IBInspectable GradientView (linear gradient, 2 stops)
import UIKit
@IBDesignable
class GradientView: UIView {
@IBInspectable var startColor: UIColor = UIColor.whiteColor() {
didSet {