You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SR-5475 Can't set property declared optional in protocol
Issue Description:
Public bug for <rdar://problem/15233922> "Cannot assign to a property through AnyObject"
I'm attempting to implement NSOpenSavePanelDelegate in a Sandboxed Mac app.
The `sender: Any` parameter is a private system class that I cannot cast to. The private classes do not inherit from the public alternatives, so I cannot cast to those either.
I'm forced to use AnyObject. But doing so results in the error `Cannot assign to immutable expression`.
Sample Code:
extensionPanelController:NSOpenSavePanelDelegate{func panel(_ sender:Any, didChangeToDirectoryURL url:URL?){
switch sender {case is NSSavePanel:()// falsecase is NSOpenPanel:()// falsedefault:print("Sandboxed app. Uses private PowerBox open/save panel classes such as NSVBOpenPanel")}varpanel= sender asAnyObject// Error: Cannot assign to immutable expression of type 'URL?'
panel.directoryURL?=URL(fileURLWithPath:"/")!
}}
Environment
Swift 4.2, Xcode 10
Additional Detail from JIRA
md5: fecd1beb40b55f31a3a7e32235cd1f19
relates to:
Issue Description:
Public bug for <rdar://problem/15233922> "Cannot assign to a property through AnyObject"
I'm attempting to implement NSOpenSavePanelDelegate in a Sandboxed Mac app.
The `sender: Any` parameter is a private system class that I cannot cast to. The private classes do not inherit from the public alternatives, so I cannot cast to those either.
I'm forced to use AnyObject. But doing so results in the error `Cannot assign to immutable expression`.
Sample Code:
Also posted in the Swift Forums here:
https://forums.swift.org/t/anyobject-parameter-cannot-assign-to-immutable-expression/16642
The text was updated successfully, but these errors were encountered: