Afnetworking: Logic error in AFURLRequestSerialization.h

Created on 7 Apr 2017  路  8Comments  路  Source: AFNetworking/AFNetworking

Line 646: @property (readwrite, nonatomic, copy) NSMutableURLRequest *request;

Using AFNetworking (3.1.0)

Logic error
Property of mutable type 'NSMutableURLRequest' has 'copy' attribute; an immutable object will be stored instead

help wanted

Most helpful comment

https://developer.apple.com/videos/play/wwdc2017/411/

Or can explicit change the setter to _ request = [request mutableCopy]; it would be more friendly.

All 8 comments

I have the same problem, when analyzing the project.

I have the same problem, when analyzing the project in Xcode 8.3.2
How to solve this problem?

This would be a great thing to have fixed. That said, it's an analyzer issue and you can probably just ignore it.

@property (readwrite, nonatomic, strong) NSMutableURLRequest *request;
self.request = [urlRequest mutableCopy];

https://developer.apple.com/videos/play/wwdc2017/411/

Or can explicit change the setter to _ request = [request mutableCopy]; it would be more friendly.

@ghmlee Great suggestion, thank you.
We have changed this manually in our production code as we want to ship apps without any Xcode warnings, both from Compiler and Analyzer.

@SlaunchaMan Hi, it's great to finally see a new official release (3.2.0).
It would be great to have these Xcode warnings solved as well.
Can I contribute by creating a PR?

Version 3.2.0 contains the following setter, which was added in commit https://github.com/AFNetworking/AFNetworking/commit/00addee8a11a21b3a32b140f404d7443664b1e4f:

- (void)setRequest:(NSMutableURLRequest *)request
{
    _request = [request mutableCopy];
}

As a result Xcode Analyzer doesn't complain anymore. Verified with Xcode 9.2.

This issue can be closed.

Was this page helpful?
0 / 5 - 0 ratings