<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 <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> 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=""><<a href="mailto:rmann@latencyzero.com" target="_blank" class="">rmann@latencyzero.com</a>></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="">
> On Sep 13, 2017, at 18:11 , Zhao Xin <<a href="mailto:owenzx@gmail.com" class="">owenzx@gmail.com</a>> wrote:<br class="">
><br class="">
</span><div class="HOEnZb"><div class="h5">> Change `self` to `ModelFetcher`. You are calling a class static property, not a class instance property.<br class="">
><br class="">
> Zhao Xin<br class="">
><br class="">
> On Thu, Sep 14, 2017 at 8:37 AM, Rick Mann via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:<br class="">
> Moving to Swift 4, I'm running into an issue for which I can't seem to find an answer in google:<br class="">
><br class="">
> "Cannot use mutating member on immutable value: 'self' is immutable"<br class="">
><br class="">
> The code looks like:<br class="">
><br class="">
> class<br class="">
> ModelFetcher : NSObject, URLSessionDelegate<br class="">
> {<br class="">
> ...<br class="">
> static let managerDispatchQueue = DispatchQueue(label: "Model Download Manager Queue")<br class="">
> static var pendingFetchers = [ModelFetcher]()<br class="">
> static var currentFetcher: ModelFetcher?<br class="">
><br class="">
> class<br class="">
> func<br class="">
> startNextFetcher()<br class="">
> {<br class="">
> self.managerDispatchQueue.<wbr class="">async<br class="">
> {<br class="">
> guard<br class="">
> self.currentFetcher == nil,<br class="">
> let mf = self.pendingFetchers.popFirst(<wbr class="">)<br class="">
> ~~~~ ^ error: cannot use mutating member on immutable value: 'self' is immutable<br class="">
> else<br class="">
> {<br class="">
> return<br class="">
> }<br class="">
><br class="">
> self.currentFetcher = mf<br class="">
> mf.start()<br class="">
> }<br class="">
> }<br class="">
> ...<br class="">
> }<br class="">
><br class="">
> 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="">
><br class="">
><br class="">
> --<br class="">
> Rick Mann<br class="">
> <a href="mailto:rmann@latencyzero.com" class="">rmann@latencyzero.com</a><br class="">
><br class="">
><br class="">
> ______________________________<wbr class="">_________________<br class="">
> swift-users mailing list<br class="">
> <a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">
> <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="">
><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>