Skip to content

Instantly share code, notes, and snippets.

View DaveBatton's full-sized avatar
💭
Eat, Sleep, Code, Repeat

Dave Batton DaveBatton

💭
Eat, Sleep, Code, Repeat
View GitHub Profile
@DaveBatton
DaveBatton / -stealImagesFromView:
Last active January 4, 2016 01:19
Saves any images found in the specified view or any of its subviews. Images are saved in the application's Documents directory.
- (void)stealImagesFromView:(UIView *)view
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder
for (UIView *subview in view.subviews) {
if ([subview isKindOfClass:[UIImageView class]]) {
UIImageView *imageView = (UIImageView *)subview;
if (imageView.image) {
NSString *filename = [NSString stringWithFormat:@"image (%f)", [NSDate timeIntervalSinceReferenceDate]];
@DaveBatton
DaveBatton / colorizeView.m
Last active January 4, 2016 01:29
Sets the backgroundColor of the specified view and all of its subviews. A tool to help debug iOS UI issues.
- (void)colorizeView:(UIView *)view
{
static CGFloat alpha = 0.1f;
view.backgroundColor = [[UIColor blueColor] colorWithAlphaComponent:alpha];
alpha += 0.1f;
for (UIView *subview in view.subviews) {
[self colorizeView:subview];
}
@DaveBatton
DaveBatton / StealImages.swift
Last active December 10, 2015 17:45
Saves any images found in the specified view or any of its subviews. Images are saved in the application's Documents directory.
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
flightView.hidden = false
stealImagesFromView(view)
}
private func stealImagesFromView(view: UIView) {
let paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
let documentsDirectory = paths.first!
//
// MCFetchedResultsViewController.m
// MoneyCarta
//
// Created by Dave Batton on 5/5/15.
// Copyright (c) 2015 Project Black. All rights reserved.
//
#import "MCFetchedResultsViewController.h"
#import "AppDelegate.h"
//
// MCFetchedResultsViewController.h
//
//
// Created by Dave Batton on 5/10/15.
//
#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>
#import "MCTemporaryContextViewController.h"