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
- (NSURL *)makeURLWithDirectoryPath:(NSURL *)url; | |
{ | |
return [url URLByAppendingPathComponent:@""]; | |
} |
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)atomicCopyItemAtURL:(NSURL *)sourceURL | |
toURL:(NSURL *)destinationURL | |
error:(NSError **)outError | |
{ | |
NSFileManager *manager = [NSFileManager defaultManager]; | |
// First copy into a temporary location where failure doesn't matter | |
NSURL *tempDir = [manager URLForDirectory:NSItemReplacementDirectory | |
inDomain:NSUserDomainMask | |
appropriateForURL:destinationURL |
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)viewWillAppear:(BOOL)animated | |
{ | |
[super viewWillAppear:animated]; | |
BOOL inMultipleSelectionMode = (self.tableView.editing ? | |
self.tableView.allowsMultipleSelectionDuringEditing : | |
self.tableView.allowsMultipleSelection); | |
NSIndexPath *selectedRowIndexPath = [self.tableView indexPathForSelectedRow]; | |
if (selectedRowIndexPath && !inMultipleSelectionMode) { |
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
- (BOOL)attemptRecoveryFromPossibleCascadeDeleteRuleFailureError:(NSError *)error; | |
{ | |
// Make sure it's an unknown validation error for a managed object | |
if ([error code] != NSManagedObjectValidationError) return NO; | |
if (![[error domain] isEqualToString:NSCocoaErrorDomain]) return NO; | |
NSManagedObject *object = [[error userInfo] objectForKey:NSValidationObjectErrorKey]; | |
if (![object isKindOfClass:[NSManagedObject class]]) return NO; | |
NSString *key = [[error userInfo] objectForKey:NSValidationKeyErrorKey]; |
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)layoutSubviews { | |
if (self.detailTextLabel.text.length) { | |
[self.contentView addSubview:self.detailTextLabel]; | |
} | |
[super layoutSubviews]; | |
} |
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
NSURLComponents *components = [NSURLComponents componentsWithString:input]; | |
// Re-encode + symbols so NSURLQueryItem recognises them as spaces | |
components.percentEncodedQuery = [components.percentEncodedQuery | |
stringByReplacingOccurrencesOfString:@"+" | |
withString:@"%20"]; | |
NSArray *items = components.queryItems; | |
// Enumerate and handle the items |
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)mergeChangesFromSaveNotification:(NSNotification *)notification | |
intoContext:(NSManagedObjectContext *)context { | |
// NSManagedObjectContext's merge routine ignores updated objects which aren't | |
// currently faulted in. To force it to notify interested clients that such | |
// objects have been refreshed (e.g. NSFetchedResultsController) we need to | |
// force them to be faulted in ahead of the merge | |
NSSet *updated = [notification.userInfo objectForKey:NSUpdatedObjectsKey]; | |
for (NSManagedObject *anObject in updated) { |
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
NSURL *url = [NSURL URLWithString:@"http://example.com/path "]; |
NewerOlder