Revision: 29073
          http://sourceforge.net/p/bibdesk/svn/29073
Author:   hofman
Date:     2025-02-27 00:08:35 +0000 (Thu, 27 Feb 2025)
Log Message:
-----------
Pass dowwnload task and delegate in init, make delegate weak

Modified Paths:
--------------
    trunk/bibdesk/BDSKDownloader.h
    trunk/bibdesk/BDSKDownloader.m

Modified: trunk/bibdesk/BDSKDownloader.h
===================================================================
--- trunk/bibdesk/BDSKDownloader.h      2025-02-26 22:10:34 UTC (rev 29072)
+++ trunk/bibdesk/BDSKDownloader.h      2025-02-27 00:08:35 UTC (rev 29073)
@@ -63,12 +63,14 @@
 @interface BDSKDownload : NSObject {
     NSURLSessionTask *task;
     NSMutableData *data;
-    id <BDSKDownloadDelegate> delegate;
+    __weak id <BDSKDownloadDelegate> delegate;
     BOOL receivedExpectedBytes;
 }
 
-@property (nonatomic, nullable, strong) id <BDSKDownloadDelegate> delegate;
-@property (nonatomic, nullable, strong) NSURLSessionTask *task;
+- (instancetype)initWithTask:(NSURLSessionTask *)task delegate:(id 
<BDSKDownloadDelegate>)delegate;
+
+@property (nonatomic, nullable, weak) id <BDSKDownloadDelegate> delegate;
+@property (nonatomic, readonly) NSURLSessionTask *task;
 @property (nonatomic, nullable, readonly) NSURLResponse *response;
 @property (nonatomic, nullable, strong) NSMutableData *data;
 @property (nonatomic) BOOL receivedExpectedBytes;

Modified: trunk/bibdesk/BDSKDownloader.m
===================================================================
--- trunk/bibdesk/BDSKDownloader.m      2025-02-26 22:10:34 UTC (rev 29072)
+++ trunk/bibdesk/BDSKDownloader.m      2025-02-27 00:08:35 UTC (rev 29073)
@@ -84,9 +84,7 @@
 }
 
 - (BDSKDownload *)addDownloadWithTask:(NSURLSessionTask *)task delegate:(id 
<BDSKDownloadDelegate>)delegate {
-    BDSKDownload *download = [[BDSKDownload alloc] init];
-    [download setTask:task];
-    [download setDelegate:delegate];
+    BDSKDownload *download = [[BDSKDownload alloc] initWithTask:task 
delegate:delegate];
     [downloads setObject:download forKey:task];
     return download;
 }
@@ -244,6 +242,15 @@
 @synthesize delegate, task, data, receivedExpectedBytes;
 @dynamic response;
 
+- (instancetype)initWithTask:(NSURLSessionTask *)aTask 
delegate:(id<BDSKDownloadDelegate>)aDelegate {
+    self = [super init];
+    if (self) {
+        task = aTask;
+        delegate = aDelegate;
+    }
+    return self;
+}
+
 - (NSURLResponse *)response {
     return [[self task] response];
 }

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



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to