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
// | |
// KSIsNotNSNotFound.h | |
// Sandvox | |
// | |
// Created by Mike on 16/01/2011. | |
// Copyright 2011 Karelia Software. All rights reserved. | |
// | |
#import <Cocoa/Cocoa.h> |
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
- (void)willTurnIntoFault; | |
{ | |
[super willTurnIntoFault]; | |
if ([self observationInfo]) | |
{ | |
NSLog(@"%@ has observers:\n%@", [self objectID], [self observationInfo]); | |
} | |
} |
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
#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_5 | |
- (void)didInsertNode:(NSTreeNode *)node; | |
{ | |
// See if model matches tree state. Leopard gets them out of sync, adding to the model rather than inserting | |
id object = [node representedObject]; | |
NSIndexPath *indexPath = [node indexPath]; | |
NSUInteger index = [indexPath lastIndex]; | |
NSTreeNode *parent = [node parentNode]; |
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
- (NSError *)application:(NSApplication *)theApplication | |
willPresentError:(NSError *)error | |
{ | |
// Log the error to the console for debugging | |
NSLog(@"Application will present error:\n%@", [error description]); | |
return error; | |
} |
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
- (NSString *)debugDescription; | |
{ | |
// Log the entirety of domain, code, userInfo for debugging. | |
// Operates recursively on underlying errors | |
NSMutableDictionary *dictionaryRep = [[self userInfo] mutableCopy]; | |
[dictionaryRep setObject:[self domain] | |
forKey:@"domain"]; | |
[dictionaryRep setObject:[NSNumber numberWithInteger:[self code]] |
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
[[self managedObjectContext] processPendingChanges]; | |
[[[self managedObjectContext] undoManager] disableUndoRegistration]; | |
// Make your special changes to the managed object | |
[[self managedObjectContext] processPendingChanges]; | |
[[[self managedObjectContext] undoManager] enableUndoRegistration]; |
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
[[NSNotificationCenter defaultCenter] | |
postNotificationName:NSUndoManagerCheckpointNotification | |
object:undoManager]; | |
[undoManager disableUndoRegistration]; | |
// Make your special changes to the managed object | |
[[NSNotificationCenter defaultCenter] | |
postNotificationName:NSUndoManagerCheckpointNotification | |
object:undoManager]; | |
[undoManager enableUndoRegistration]; |
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
- (void)willRemoveObject:(id)object; | |
{ | |
// Put your removal handling code here | |
} | |
- (void)removeObjects:(NSArray *)objects | |
{ | |
// -removeObject: calls this method internally. | |
// Iterate the objects, reporting each one | |
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
- (BOOL)ks_isDescendantOfNode:(NSTreeNode *)aNode; | |
{ | |
NSTreeNode *testNode = self; | |
while (testNode) | |
{ | |
if (testNode == aNode) return YES; | |
testNode = [testNode parentNode]; | |
} | |
return NO; |
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
- (void)clearRecentDocumentURL:(NSURL *)url; | |
{ | |
NSArray *recentDocs = [self recentDocumentURLs]; | |
[self clearRecentDocuments:self]; | |
// Must enumerate backwards to register in the correct order | |
for (NSURL *aURL in [recentDocs reverseObjectEnumerator]) | |
{ | |
if (![aURL ks_isEqualToURL:url]) | |
{ |
OlderNewer