<div dir="ltr"><div class="gmail_default"><font face="georgia, serif">Change `self` to `ModelFetcher`. You are calling a class static property, not a class instance property.</font></div><div class="gmail_default"><font face="georgia, serif"><br></font></div><div class="gmail_default"><font face="georgia, serif">Zhao Xin</font></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 14, 2017 at 8:37 AM, Rick Mann via swift-users <span dir="ltr">&lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Moving to Swift 4, I&#39;m running into an issue for which I can&#39;t seem to find an answer in google:<br>
<br>
&quot;Cannot use mutating member on immutable value: &#39;self&#39; is immutable&quot;<br>
<br>
The code looks like:<br>
<br>
class<br>
ModelFetcher : NSObject, URLSessionDelegate<br>
{<br>
    ...<br>
    static  let     managerDispatchQueue                    =   DispatchQueue(label: &quot;Model Download Manager Queue&quot;)<br>
    static  var     pendingFetchers                         =   [ModelFetcher]()<br>
    static  var     currentFetcher:         ModelFetcher?<br>
<br>
    class<br>
    func<br>
    startNextFetcher()<br>
    {<br>
        self.managerDispatchQueue.<wbr>async<br>
        {<br>
            guard<br>
                self.currentFetcher == nil,<br>
                let mf = self.pendingFetchers.popFirst(<wbr>)<br>
                         ~~~~ ^                             error: cannot use mutating member on immutable value: &#39;self&#39; is immutable<br>
            else<br>
            {<br>
                return<br>
            }<br>
<br>
            self.currentFetcher = mf<br>
            mf.start()<br>
        }<br>
    }<br>
    ...<br>
}<br>
<br>
This code compiled fine in Xcode 8, or in Xcode 9/Swift 3.2 as a monolithic app (the error shows up when this code is factored into a framework). Other mutating references to self seem to compile okay (e.g. &quot;self.currentFetcher = nil&quot; or &quot;self.pendingFetchers.remove(<wbr>at: idx)&quot;). Not sure what&#39;s special about this one.<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
Rick Mann<br>
<a href="mailto:rmann@latencyzero.com">rmann@latencyzero.com</a><br>
<br>
<br>
______________________________<wbr>_________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br>
</font></span></blockquote></div><br></div>