<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>I think there’s something strange with popFirst. It doesn’t show up in the autocomplete in Xcode, but it compiles, and popLast doesn’t throw the same error. removeFirst doesn’t either, though it’s unsafe. Weird.<div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Jon</div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Sep 13, 2017, at 9:47 PM, Zhao Xin via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:georgia,serif">I begin to think it is related to how you `<span style="font-family:arial,sans-serif;font-size:12.800000190734863px" class="">popFirst(</span><wbr style="font-family:arial,sans-serif;font-size:12.800000190734863px" class=""><span style="font-family:arial,sans-serif;font-size:12.800000190734863px" class="">)` implemented. Check it or post it here.</span></div><div class="gmail_default" style="font-family:georgia,serif"><span style="font-family:arial,sans-serif;font-size:12.800000190734863px" class=""><br class=""></span></div><div class="gmail_default" style="font-family:georgia,serif"><span style="font-family:arial,sans-serif;font-size:12.800000190734863px" class="">Zhao Xin</span></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Sep 14, 2017 at 9:36 AM, Roderick Mann <span dir="ltr" class="">&lt;<a href="mailto:rmann@latencyzero.com" target="_blank" class="">rmann@latencyzero.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Yeah, that's not it. I made the change you suggested, I get the same error.<br class="">
<span class="im HOEnZb"><br class="">
&gt; On Sep 13, 2017, at 18:11 , Zhao Xin &lt;<a href="mailto:owenzx@gmail.com" class="">owenzx@gmail.com</a>&gt; wrote:<br class="">
&gt;<br class="">
</span><div class="HOEnZb"><div class="h5">&gt; Change `self` to `ModelFetcher`. You are calling a class static property, not a class instance property.<br class="">
&gt;<br class="">
&gt; Zhao Xin<br class="">
&gt;<br class="">
&gt; On Thu, Sep 14, 2017 at 8:37 AM, Rick Mann via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:<br class="">
&gt; Moving to Swift 4, I'm running into an issue for which I can't seem to find an answer in google:<br class="">
&gt;<br class="">
&gt; "Cannot use mutating member on immutable value: 'self' is immutable"<br class="">
&gt;<br class="">
&gt; The code looks like:<br class="">
&gt;<br class="">
&gt; class<br class="">
&gt; ModelFetcher : NSObject, URLSessionDelegate<br class="">
&gt; {<br class="">
&gt;&nbsp; &nbsp; &nbsp;...<br class="">
&gt;&nbsp; &nbsp; &nbsp;static&nbsp; let&nbsp; &nbsp; &nbsp;managerDispatchQueue&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =&nbsp; &nbsp;DispatchQueue(label: "Model Download Manager Queue")<br class="">
&gt;&nbsp; &nbsp; &nbsp;static&nbsp; var&nbsp; &nbsp; &nbsp;pendingFetchers&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=&nbsp; &nbsp;[ModelFetcher]()<br class="">
&gt;&nbsp; &nbsp; &nbsp;static&nbsp; var&nbsp; &nbsp; &nbsp;currentFetcher:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ModelFetcher?<br class="">
&gt;<br class="">
&gt;&nbsp; &nbsp; &nbsp;class<br class="">
&gt;&nbsp; &nbsp; &nbsp;func<br class="">
&gt;&nbsp; &nbsp; &nbsp;startNextFetcher()<br class="">
&gt;&nbsp; &nbsp; &nbsp;{<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;self.managerDispatchQueue.<wbr class="">async<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;guard<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;self.currentFetcher == nil,<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;let mf = self.pendingFetchers.popFirst(<wbr class="">)<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ~~~~ ^&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;error: cannot use mutating member on immutable value: 'self' is immutable<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br class="">
&gt;<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;self.currentFetcher = mf<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mf.start()<br class="">
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br class="">
&gt;&nbsp; &nbsp; &nbsp;}<br class="">
&gt;&nbsp; &nbsp; &nbsp;...<br class="">
&gt; }<br class="">
&gt;<br class="">
&gt; 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. "self.currentFetcher = nil" or "self.pendingFetchers.remove(<wbr class="">at: idx)"). Not sure what's special about this one.<br class="">
&gt;<br class="">
&gt;<br class="">
&gt; --<br class="">
&gt; Rick Mann<br class="">
&gt; <a href="mailto:rmann@latencyzero.com" class="">rmann@latencyzero.com</a><br class="">
&gt;<br class="">
&gt;<br class="">
&gt; ______________________________<wbr class="">_________________<br class="">
&gt; swift-users mailing list<br class="">
&gt; <a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">
&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank" class="">https://lists.swift.org/<wbr class="">mailman/listinfo/swift-users</a><br class="">
&gt;<br class="">
<br class="">
<br class="">
</div></div><span class="HOEnZb"><font color="#888888" class="">--<br class="">
Rick Mann<br class="">
<a href="mailto:rmann@latencyzero.com" class="">rmann@latencyzero.com</a><br class="">
<br class="">
<br class="">
</font></span></blockquote></div><br class=""></div>
_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></div></body></html>