Revision: 29363
          http://sourceforge.net/p/bibdesk/svn/29363
Author:   hofman
Date:     2025-07-25 15:30:08 +0000 (Fri, 25 Jul 2025)
Log Message:
-----------
create all linked file and url key with format

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

Modified: trunk/bibdesk/BibItem.m
===================================================================
--- trunk/bibdesk/BibItem.m     2025-07-25 15:25:15 UTC (rev 29362)
+++ trunk/bibdesk/BibItem.m     2025-07-25 15:30:08 UTC (rev 29363)
@@ -4156,14 +4156,19 @@
     if (biFlags.createdFilesArray)
         return;
     
-    NSUInteger i = 1;
-    NSString *value, *key = @"Bdsk-File-1";
-    
     NSMutableArray *keysToRemove = [NSMutableArray new];
     NSMutableArray *unresolvedFiles = [NSMutableArray new];
     NSMutableArray *unresolvedURLs = [NSMutableArray new];
     
-    while ((value = [pubFields objectForKey:key]) != nil) {
+    NSUInteger i = 0;
+    
+    while (YES) {
+        // next key in the sequence; increment i first, so it's guaranteed 
correct
+        NSString *key = [NSString stringWithFormat:@"Bdsk-File-%lu", (unsigned 
long)++i];
+        NSString *value = [pubFields objectForKey:key];
+        if (value == nil)
+            break;
+        
         BDSKLinkedFile *aFile = [[BDSKLinkedFile alloc] 
initWithBase64String:value delegate:self];
         if (aFile) {
             [files addObject:aFile];
@@ -4173,16 +4178,18 @@
             NSLog(@"*** error *** -[BDSKLinkedFile 
initWithBase64String:delegate:] failed (%@ of %@)", key, [self citeKey]);
         }
         [keysToRemove addObject:key];
-        
-        // next key in the sequence; increment i first, so it's guaranteed 
correct
-        key = [NSString stringWithFormat:@"Bdsk-File-%lu", (unsigned long)++i];
     }
     
     // reset i so we can get all of the remote URL types
-    i = 1;
-    key = @"Bdsk-Url-1";
+    i = 0;
     
-    while ((value = [pubFields objectForKey:key]) != nil) {
+    while (YES) {
+        // next key in the sequence; increment i first, so it's guaranteed 
correct
+        NSString *key = [NSString stringWithFormat:@"Bdsk-Url-%lu", (unsigned 
long)++i];
+        NSString *value = [pubFields objectForKey:key];
+        if (value == nil)
+            break;
+
         BDSKLinkedFile *aURL = [[BDSKLinkedFile alloc] 
initWithURLString:value];
         if (aURL) {
             [files addObject:aURL];
@@ -4192,9 +4199,6 @@
             NSLog(@"*** error *** -[BDSKLinkedFile initWithURLString:] failed 
(%@ of %@)", key, [self citeKey]);
         }
         [keysToRemove addObject:key];
-        
-        // next key in the sequence; increment i first, so it's guaranteed 
correct
-        key = [NSString stringWithFormat:@"Bdsk-Url-%lu", (unsigned long)++i];
     }
     
     if ([owner fileURL])

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