Skip to content

Instantly share code, notes, and snippets.

View rsaunders100's full-sized avatar

Rob Saunders rsaunders100

View GitHub Profile
@rsaunders100
rsaunders100 / alert.m
Created September 19, 2011 09:35
(iOS) UIAlert View Example - Has a delegate for Yes/No Taps Will only display popup once
- (void) showConfirmationAlert
{
// A quick and dirty popup, displayed only once
if (![[NSUserDefaults standardUserDefaults] objectForKey:@"HasSeenPopup"])
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Question"
message:@"Do you like cats?"
delegate:self
cancelButtonTitle:@"No"
otherButtonTitles:@"Yes",nil];
@rsaunders100
rsaunders100 / BGBlock.m
Created October 19, 2011 16:29
(iOS) Simple Background - Main Thread with blocks
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^
{
// Do heavy lifting
// Back to the main thread with the result
dispatch_sync(dispatch_get_main_queue(), ^
{
// Update UI etc
}
}
@rsaunders100
rsaunders100 / UIView+Snapshots.m
Created January 31, 2012 14:11
(iOS) Take image snapshots of the current state of a view.
@interface UIView (UIView_Snapshots)
// Take image snapshots of the current state of a view.
// Use the background color of the superview if you have rounded corners
// If background color is nil the background will be treated as transparent
- (UIImage*) imageOfViewUsingBackgroundColor:(UIColor*)backgroundColorOrNil;
// Will save to the documents directory as XXXX.png
- (void) saveImageOfViewToPNGNamed:(NSString*)fileNameMinusExtension usingBackgroundColor:(UIColor*)backgroundColorOrNil;
@rsaunders100
rsaunders100 / UIImage+ImageSplitting.h
Created February 3, 2012 15:02
(iOS) Split an image into an array of evenly sized CALayers
//
// UIImage+ImageSplitting.h
// Test
//
// Created by Robert Saunders on 03/02/2012.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@rsaunders100
rsaunders100 / UIView+ViewExpanding.h
Created March 2, 2012 17:38
UIView+ViewExpanding.h
//
// UIView+ViewExpanding.h
// VodafoneTest
//
// Created by Robert Saunders on 02/03/2012.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@rsaunders100
rsaunders100 / AppReSigner.scpt
Created March 22, 2012 17:29
Re-sign .ipa files and replace the embedded.mobileprovision
-- Erica Sadun, http://ericasadun.com
-- iPhone Developer's Cookbook, 3.0 Edition
-- BSD License, Use at your own risk
-- Adapted by Rob Saunders to also replace embeded profiles
--
--
-- save in Script Editor as Application
-- drag files to its icon in Finder
@rsaunders100
rsaunders100 / KDPersistantCache.h
Created April 18, 2012 15:53
Persistently stores and recovers NSCoding compliant objects with a expiry time
//
// KDPersistantCache.h
// KDPrototype
// Stores NSCoding compliant objects persistantly in the NSCachesDirectory
// for a specified period of time.
//
// Created by on 18/04/2012.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
@rsaunders100
rsaunders100 / UIView+ViewArranging.h
Created May 15, 2012 17:39
(iOS) Make a view with given subviews arranged linearly (either horizontally or vertically)
//
// UIView+ViewArranging.h
// Created by on 15/05/2012.
//
#import <UIKit/UIKit.h>
typedef enum {
ViewArrangingDirectionHorizontal,
ViewArrangingDirectionVertical
@rsaunders100
rsaunders100 / UIImage+Transform.h
Created October 4, 2012 17:25
Transform an image threadsafe
//
// UIImage+Transform.h
// TestImage
//
// Created by Robert Saunders on 04/10/2012.
// Copyright (c) 2012 Robert Saunders. All rights reserved.
//
#import <UIKit/UIKit.h>
@rsaunders100
rsaunders100 / gist:6056183
Created July 22, 2013 18:17
Demonstrates the various NSDataWritingOptions. Should be used with a program like iExplorer to see how these file behave. http://www.macroplant.com/iexplorer/
[MyClass writeStringWithFileName:@"Complete"
option:NSDataWritingFileProtectionComplete];
[MyClass writeStringWithFileName:@"CompleteUnlessOpen"
option:NSDataWritingFileProtectionCompleteUnlessOpen];
[MyClass writeStringWithFileName:@"CompleteUntilFirstUserAuthentication"
option:NSDataWritingFileProtectionCompleteUntilFirstUserAuthentication];
[MyClass writeStringWithFileName:@"None"