我使用SCDynamicStoreCopyProxies
来检索代理信息。我希望,一旦我有了字典,我就可以设置当前的代理设置。原来,SCDynamicStoreCopyProxies
返回的字典是只读的。如何更改当前的代理设置?
到目前为止我尝试过:
func setNet(){
let ds: SCDynamicStoreRef = SCDynamicStoreCreate(nil, "setNet" as
CFString, nil, nil)!
let list = SCDynamicStoreCopyProxies(ds)
print(list!)
if let list = SCDynamicStoreCopyProxies(ds) as NSDictionary? {
if let port = list["HTTPPort"] as? Int {
print("HTTPPort:", port)
list["HTTPPort"] = 8088; // error, subscript is get-only
}
}
}
答案 0 :(得分:0)
要更改“只读”(又名非变异)字典,请使用func mutableCopy() -> AnyObject
。