Skip to content

Commit

Permalink
mark data property with copy instead
Browse files Browse the repository at this point in the history
  • Loading branch information
woshimaliang committed Mar 11, 2024
1 parent 3f1997c commit 531b653
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion PINFuture/Classes/Categories/NSURLSession+PINFuture.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ - (PINNSURLSessionDataTaskAndResult *)pinfuture_dataTaskWithRequest:(NSURLReques
PINFuture<PINNSURLSessionDataTaskResult *> *future;
future = [PINFuture<PINNSURLSessionDataTaskResult *> withBlock:^(void (^ _Nonnull resolve)(id _Nonnull), void (^ _Nonnull reject)(NSError * _Nonnull)) {
task = [self dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
PINNSURLSessionDataTaskResult *result = [PINNSURLSessionDataTaskResult resultWithData:[data copy] response:response error:error];
PINNSURLSessionDataTaskResult *result = [PINNSURLSessionDataTaskResult resultWithData:data response:response error:error];
resolve(result);
}];
task.priority = priority;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface PINNSURLSessionDataTaskResult : NSObject

@property (nonatomic, readonly) NSData * _Nullable data;
@property (nonatomic, readonly) NSURLResponse * _Nullable response;
@property (nonatomic, copy, readonly) NSURLResponse * _Nullable response;
@property (nonatomic, readonly) NSError * _Nullable error;

+ (instancetype)resultWithData:(NSData * _Nullable)data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
NS_ASSUME_NONNULL_BEGIN

@interface PINNSURLSessionDataTaskResult ()
@property (nonatomic) NSData * _Nullable data;
@property (nonatomic, copy) NSData * _Nullable data; //intentionally use copy as the network data might be NSMutableData under the hood
@property (nonatomic) NSURLResponse * _Nullable response;
@property (nonatomic) NSError * _Nullable error;
@end
Expand Down

0 comments on commit 531b653

Please sign in to comment.