Updated to modern Obj-C

This commit is contained in:
Michael Starke
2021-02-17 17:56:21 +01:00
parent 84f35d6005
commit 3c4eac6707

View File

@@ -28,13 +28,12 @@
@implementation MPDocumentWindowDelegate @implementation MPDocumentWindowDelegate
- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender { - (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender {
MPDocument *document = sender.draggingDestinationWindow.windowController.document;
MPDocument *document = [[[sender draggingDestinationWindow] windowController] document];
if(document.encrypted) { if(document.encrypted) {
return NSDragOperationNone; return NSDragOperationNone;
} }
NSPasteboard *draggingPasteBoard = [sender draggingPasteboard]; NSPasteboard *draggingPasteBoard = sender.draggingPasteboard;
NSArray *arrayOfURLs = [draggingPasteBoard readObjectsForClasses:@[NSURL.class] options:nil]; NSArray *arrayOfURLs = [draggingPasteBoard readObjectsForClasses:@[NSURL.class] options:nil];
BOOL ok = YES; BOOL ok = YES;
@@ -52,7 +51,7 @@
} }
- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender { - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender {
NSPasteboard *draggingPasteBoard = [sender draggingPasteboard]; NSPasteboard *draggingPasteBoard = sender.draggingPasteboard;
NSArray *arrayOfURLs = [draggingPasteBoard readObjectsForClasses:@[NSURL.class] options:nil]; NSArray *arrayOfURLs = [draggingPasteBoard readObjectsForClasses:@[NSURL.class] options:nil];
NSURL *url = arrayOfURLs.lastObject; NSURL *url = arrayOfURLs.lastObject;
@@ -60,7 +59,7 @@
return NO; return NO;
} }
/* Currently not working, as the underlying operations do not get the undomanager */ /* Currently not working, as the underlying operations do not get the undomanager */
MPDocument *document = [sender draggingDestinationWindow].windowController.document; MPDocument *document = sender.draggingDestinationWindow.windowController.document;
KPKGroup *parentGroup = document.selectedGroups.count == 1 ? document.selectedGroups.firstObject : document.root; KPKGroup *parentGroup = document.selectedGroups.count == 1 ? document.selectedGroups.firstObject : document.root;
[document.undoManager beginUndoGrouping]; [document.undoManager beginUndoGrouping];
KPKEntry *entry = [document createEntry:parentGroup]; KPKEntry *entry = [document createEntry:parentGroup];