Revision: 29811
          http://sourceforge.net/p/bibdesk/svn/29811
Author:   hofman
Date:     2025-11-15 16:43:23 +0000 (Sat, 15 Nov 2025)
Log Message:
-----------
implement initWithURL:delegate: with bookmark in partially abstract superclass

Modified Paths:
--------------
    trunk/bibdesk/BDSKLinkedFile.m

Modified: trunk/bibdesk/BDSKLinkedFile.m
===================================================================
--- trunk/bibdesk/BDSKLinkedFile.m      2025-11-15 15:57:45 UTC (rev 29810)
+++ trunk/bibdesk/BDSKLinkedFile.m      2025-11-15 16:43:23 UTC (rev 29811)
@@ -318,8 +318,19 @@
 }
 
 - (instancetype)initWithURL:(NSURL *)aURL 
delegate:(id<BDSKLinkedFileDelegate>)aDelegate {
-    BDSKASSERT_NOT_REACHED("Attempt to initialize BDSKLinkedAliasFile directly 
with a URL");
-    return nil;
+    BDSKASSERT([aURL isFileURL]);
+    
+    NSString *aPath = [aURL path];
+    
+    BDSKASSERT(nil != aPath);
+    
+    NSString *basePath = [aDelegate basePathForLinkedFile:self];
+    NSString *relPath = basePath ? [aPath relativePathFromPath:basePath] : nil;
+    NSData *anAlias = [aURL bookmarkDataWithOptions:0 
includingResourceValuesForKeys:nil relativeToURL:nil error:NULL];
+    self = [self initWithAlias:anAlias relativePath:relPath 
delegate:aDelegate];
+    if (self && basePath)
+        [self updateFileURL];
+    return self;
 }
 
 - (instancetype)initWithBase64String:(NSString *)base64String 
delegate:(id<BDSKLinkedFileDelegate>)aDelegate {
@@ -542,6 +553,7 @@
 }
 
 // always encode subclasses as BDSKLinkedAliasFile
+// it will warn when this is merely inherited from a superclass
 - (Class)classForCoder { return BDSKLinkedAliasFileClass; }
 - (Class)classForArchiver { return BDSKLinkedAliasFileClass; }
 - (Class)classForKeyedArchiver { return BDSKLinkedAliasFileClass; }
@@ -772,23 +784,8 @@
 
 @implementation BDSKBookmarkLinkedFile
 
-- (instancetype)initWithURL:(NSURL *)aURL 
delegate:(id<BDSKLinkedFileDelegate>)aDelegate {
-    BDSKASSERT([aURL isFileURL]);
-    
-    NSString *aPath = [aURL path];
-    
-    BDSKASSERT(nil != aPath);
-    
-    NSString *basePath = [aDelegate basePathForLinkedFile:self];
-    NSString *relPath = basePath ? [aPath relativePathFromPath:basePath] : nil;
-    NSData *anAlias = [aURL bookmarkDataWithOptions:0 
includingResourceValuesForKeys:nil relativeToURL:nil error:NULL];
-    self = [self initWithAlias:anAlias relativePath:relPath 
delegate:aDelegate];
-    if (self && basePath)
-        [self updateFileURL];
-    return self;
-}
-
 // always encode subclasses as BDSKLinkedAliasFile
+// it will warn when this is merely inherited from a superclass
 - (Class)classForCoder { return BDSKLinkedAliasFileClass; }
 - (Class)classForArchiver { return BDSKLinkedAliasFileClass; }
 - (Class)classForKeyedArchiver { return BDSKLinkedAliasFileClass; }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to