This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation UINavigationController(Trim) | |
-(void)trimNavigationStack { | |
NSArray *vcs = [self.viewControllers subArrayWithRange:NSMakeRange(0,self.viewControllers.count - 1)]; | |
NSString *file = [NSTemporaryDirectory() stringByAppendingPathComponent:@"trimmedVCs"]; | |
[NSKeyedArchiver archiveRootObject:vcs toFile:file]; | |
[self setViewControllers:@[self.viewControllers.lastObject] animated:NO]; | |
} | |
-(void)untrimNavigationStack { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Public, and safe since UIKit is single-threaded */ | |
+(instancetype)controllerWithParam:(id)param0 { | |
nextParam0 = param0; | |
id vc = [[UIStoryboard storyboard…] instantiateViewController…]; | |
return vc; | |
} | |
static id nextParam0; | |
-(id)initWithCoder:(NSCoder *)aDecoder { | |
self = [super initWithCoder:aDecoder]; | |
if(!self) return nil; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define kDebugMomentCount 10 | |
-(void)doDebugStuff { | |
[[TRSyncManager sharedSyncManager] suspendWithKey:@"DebugSuspension"]; | |
Trip *trip = [Trip findFirst]; // Get one somehow. withID is another good candidate | |
if(!trip) return; | |
double delayInSeconds = 1.0; // Wait for some assets to get tracked. | |
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); | |
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ | |
NSArray *assetURLs = [[[TRAssetsLibraryTracker shared] sortedAssets] subarrayWithRange:NSMakeRange(0, kDebugMomentCount)]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Cancel network requests | |
// Delete all managed objects | |
NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{ | |
NSManagedObjectContext *managedObjectContext = [RKManagedObjectStore defaultStore].persistentStoreManagedObjectContext; | |
[managedObjectContext performBlockAndWait:^{ | |
NSError *error = nil; | |
for (NSEntityDescription *entity in [RKManagedObjectStore defaultStore].managedObjectModel) { | |
NSFetchRequest *fetchRequest = [NSFetchRequest new]; | |
[fetchRequest setEntity:entity]; | |
[fetchRequest setIncludesSubentities:NO]; |
NewerOlder