Skip to content

Instantly share code, notes, and snippets.

View kenthumphries's full-sized avatar

Kent Humphries kenthumphries

View GitHub Profile
extension UIViewController {
func recursiveDescription() -> String {
let description = view.perform(Selector(("recursiveDescription")))?.takeUnretainedValue() as! String
return description
}
}
@kenthumphries
kenthumphries / embed-debug-only-framework.sh
Last active October 20, 2023 14:10
Script to be called as part of an Xcode Run Script build phase. This will ensure that script Input File is copied (and code signed) to script Output File.
#!/bin/sh
# This script embeds (and codesigns) a framework within an iOS app binary, but only when the configuration is Debug.
# It must be called from, or copied into an Xcode Run Script build phase with following setup:
# Input Files:
# - Path to framework within project folder (source path)
# - For example: $(SRCROOT)/ThirdPartyFrameworks/SimulatorStatusMagiciOS.framework
# Output Files:
# - Desired path to framework within ${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH} (destination path)
# - For example: ${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/SimulatorStatusMagiciOS.framework
#import <CoreData/CoreData.h>
@implementation NSManagedObjectContext (FetchAggregates)
/**
* This method groups CoreData objects based on a list of user defined properties/relationships.
* Properties contain values, and Relationships are properties that specifically point to another NSManagedObject.
* Note: properties and relationships must be separated out as aggregate operations (count, max, min, avg) cannot be performed on relationships.
*
* NOTE: A common use for this method is finding duplicate NSManagedObject entities where 'duplicate' means exactly matching certain properties/relationships.
@kenthumphries
kenthumphries / NSManagedObject+temporaryContext.m
Last active August 29, 2015 14:26
Method to quickly perform a block using a temporary managed object context. Can be useful if you need to perform a few pre-migration optimisations to a database.
typedef NSError *(^NSManagedObjectContextBlock)(NSManagedObjectContext *context);
+ (void)performBlock:(NSManagedObjectContextBlock)block withTemporaryManagedObjectContextFromDatabaseAtURL:(NSURL *)url withModelBundle:(NSBundle *)bundle
{
NSParameterAssert(block);
if (!block)
{
return;
}