Skip to content

Instantly share code, notes, and snippets.

View quellish's full-sized avatar

Dan quellish

View GitHub Profile
@quellish
quellish / appledoc.sh
Created November 9, 2011 20:25
Xcode shell script build phase for appledoc documentation
DOCUMENTATION_DIR="Documentation"
BUNDLE_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "${BUILD_ROOT}/${INFOPLIST_PATH}")
# DOCUMENTATION_FOLDER_PATH
if [ -e /usr/local/bin/appledoc ] ; then
/usr/local/bin/appledoc --project-name $PRODUCT_NAME --output $DOCUMENTATION_DIR --logformat xcode --exit-threshold 2 --docset-bundle-filename "$BUNDLE_ID.$PRODUCT_NAME.docset" .
else
echo "AppleDoc is not installed in /usr/local/bin , you can download it from https://github.com/tomaz/appledoc"
fi
@quellish
quellish / docset.sh
Created January 25, 2012 05:08
AppleDoc docset generator script for xcode
# This can be inserted as a Run Script build phase or a Build Rule in your Xcode project.
# You can set this to whatever you like.
DOCUMENTATION_DIR="Documentation"
BUNDLE_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "${BUILD_ROOT}/${INFOPLIST_PATH}")
# DOCUMENTATION_FOLDER_PATH
if [ -e /usr/local/bin/appledoc ] ; then
/usr/local/bin/appledoc --project-name $PRODUCT_NAME --output $DOCUMENTATION_DIR --logformat xcode --exit-threshold 2 --verbose xcode --docset-bundle-filename "$BUNDLE_ID.$PRODUCT_NAME.docset" .
@quellish
quellish / gist:1772340
Created February 8, 2012 19:13
Layer Rasterization
CALayer *layer = [view layer];
layer.shouldRasterize = YES;
layer.rasterizationScale = [[UIScreen mainScreen] scale];
@quellish
quellish / CoverStory.scpt
Created April 11, 2012 10:37
Run CoverStory from Xcode build script
exec osascript <<EOF
set location to system attribute "OBJECT_FILE_DIR_normal"
tell app "CoverStory"
activate
set var to location
open var
end tell
@quellish
quellish / CoverStory.scpt
Created April 11, 2012 10:41
Run CoverStory from Xcode build script
exec osascript <<EOF
set objects_normal to system attribute "OBJECT_FILE_DIR_normal"
tell app "CoverStory"
activate
open (objects_normal as text) & "/i386"
end tell
@quellish
quellish / CoverStory.scpt
Created April 11, 2012 11:09
Run CoverStory from Xcode build script
exec osascript <<EOF
set objects_normal to system attribute "OBJECT_FILE_DIR_normal"
set fp to objects_normal & "/i386"
set posix_path to POSIX file fp
set appExists to false
tell application "Finder"
try
exists application file id "com.google.CoverStory"
@quellish
quellish / gist:3433715
Created August 23, 2012 07:06
Prefetch all relationships on managed object
NSDictionary *relationshipMap = [[fetchRequest entity] relationshipsByName];
NSArray *relationshipKeyPaths = [relationshipMap allKeys];
[fetchRequest setRelationshipKeyPathsForPrefetching:relationshipKeyPaths];
1. Add two methods to handle the notification. You want to create and add a new store when the old one has been removed.
- (void) didChangePersistentStores:(id)notification {
NSArray *addedStores = nil;
NSArray *removedStores = nil;
NSArray *uuidChangedStores = nil;
addedStores = [[notification userInfo] valueForKey:NSAddedPersistentStoresKey];
removedStores = [[notification userInfo] valueForKey:NSRemovedPersistentStoresKey];
uuidChangedStores = [[notification userInfo] valueForKey:NSUUIDChangedPersistentStoresKey];
@quellish
quellish / gist:1e09834a9ff0ec95a34d
Created July 23, 2014 16:19
recursive context save
-(void) recursiveSave:(NSManagedObjectContext *)context {
NSError *error = nil;
[context performBlock:{
if (![context save:&error]){
[self errorHandler:error];
} else {
[self recursiveSave:[context parentContext]];
}
}];
}
@quellish
quellish / kvo
Last active August 29, 2015 14:04
correct kvo observe value for key path
// in the initializer, or viewWillAppear,etc:
[self addObserver:self forKeyPath:keyPath options:options context:(__bridge void*)self];
// in dealloc, or viewDidDisappear, etc:
[self removeObserver:self forKeyPath:keyPath context:(__bridge void*)self];
- (void) observeValueForKeyPath: (NSString *) keyPath ofObject: (id) object change: (NSDictionary *) change context: (void *) context {
if ((__bridge id)context == self){