Skip to content

Instantly share code, notes, and snippets.

View danielctull's full-sized avatar

Daniel Tull danielctull

View GitHub Profile
@danielctull
danielctull / find-unused-images.sh
Created October 12, 2011 07:36
A script to find images that are not used in an iOS project. Originally from http://stackoverflow.com/questions/6113243/how-to-find-unused-images-in-an-xcode-project
#!/bin/sh
PROJ=`find . -name '*.xib' -o -name '*.[mh]'`
for png in `find . -name '*.png'`
do
name=`basename $png`
if ! grep -q $name $PROJ; then
echo "$png is not referenced"
fi
done
@danielctull
danielctull / dct_weak.h
Created November 9, 2011 12:28
ARC macros for weak references
#import <Availability.h>
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_4_3
#warning "This library uses ARC which is only available in iOS SDK 4.3 and later."
#endif
#if !defined dct_weak && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_5_0
#define dct_weak weak
#define __dct_weak __weak
#define dct_nil(x)
@danielctull
danielctull / dct_weak.h
Created December 29, 2011 02:21 — forked from rowanj/dct_weak.h
ARC macros for weak references
#ifndef _DCT_WEAK_H
#define _DCT_WEAK_H
// Macros for portable support of notionally weak properties with ARC
// Forked from https://gist.github.com/1354106
// Updated by Rowan James
// Available at https://gist.github.com/1530868
// Defines:
// dct_weak to be used as a replacement for the 'weak' keyword:
// @property (dct_weak) NSObject* propertyName;
@danielctull
danielctull / dct_weak.h
Created January 21, 2012 11:13 — forked from rowanj/dct_weak.h
ARC macros for weak references
#ifndef _DCT_WEAK_H
#define _DCT_WEAK_H
// Macros for portable support of notionally weak properties with ARC
// Contributors: Daniel Tull, Abizer Nasir, Rowan James
// Current version: https://gist.github.com/1652385
// Defines:
// dct_weak to be used as a replacement for the 'weak' keyword:
// @property (dct_weak) NSObject* propertyName;
// __dct_weak to be used as a replacement for the '__weak' variable attribute:
@danielctull
danielctull / copyClassMethods
Created June 18, 2012 13:40
A function to copy the class methods from one class to another
void copyClassMethods(Class existingClass, Class class) {
NSUInteger classMethodsCount;
Method *classMethods = class_copyMethodList(object_getClass(existingClass), &classMethodsCount);
for (int i = 0; i < classMethodsCount; i++) {
Method method = classMethods[i];
SEL selector = method_getName(method);
IMP implementation = method_getImplementation(method);
const char *types = method_getTypeEncoding(method);
class_addMethod(object_getClass(class), selector, implementation, types);
@danielctull
danielctull / NSBundle+DCTBundleWithName.h
Created July 11, 2012 10:37
NSBundle category to recursively look through directories and find a bundle with the given name
//
// NSBundle+DCTBundleWithName.h
//
// Created by Daniel Tull on 11/07/2012.
// Copyright (c) 2012 Daniel Tull. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSBundle (DCTBundleWithName)
@danielctull
danielctull / blah.m
Created July 19, 2012 11:51
New moveDown
- (void)moveDown {
NSIndexPath *indexPath = [_tableViewController.tableView indexPathForSelectedRow];
UITableViewCell *cell = [_tableViewController.tableView cellForRowAtIndexPath:indexPath];
UIView *bg = cell.selectedBackgroundView;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.selectedBackgroundView = nil;
indexPath = [NSIndexPath indexPathForRow:indexPath.row+1 inSection:indexPath.section];
[_tableViewController.tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionBottom];
@danielctull
danielctull / ThreadedManagedObjectContext.h
Created July 25, 2012 14:04
NSManagedObjectContext for iOS 4. Maybe?
/*
ThreadedManagedObjectContext.h
ThreadedManagedObjectContext
Created by Daniel Tull on 25.07.2012.
Copyright (c) 2012 Daniel Tull. All rights reserved.
@danielctull
danielctull / GlobalSettings.plist
Created August 7, 2012 14:48 — forked from samdeane/GlobalSettings.plist
Script for generating appledoc docs
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>--project-company</key>
<string>Elegant Chaos</string>
<key>--company-id</key>
<string>com.elegantchaos</string>
<key>--keep-undocumented-objects</key>
<false/>
@danielctull
danielctull / ShakeAnimation.m
Created September 7, 2012 16:14 — forked from pieteromvlee/ShakeAnimation.m
ShakeAnimation; a variant on @danielctull's versopm
@implementation ShakeAnimation {
CGRect originalRect;
NSInteger counter;
}
+ (void)shakeView:(UIView *)view {
[[[[self class] alloc] initWithView:view] shake];
}
- (id)initWithView:(UIView *)view {