Sounds ridiculous, but I'm unable to fix this piece of code:
self.runningScripts.filter({ $0 != scriptRunner })
No matter how I write the closure I always get this error:
Cannot invoke 'filter' with an argument list of type '
((_) -> _)
'
runningScripts
is defined like this:
var runningScripts = [ScriptRunner]()
and ScriptRunner
is a Swift class (does not inherit from NSObject)
I'm using nearly the same in many other places without problems. Any suggestions?
You can get that error if you didn't make ScriptRunner
conform to Equatable
:
class ScriptRunner : Equatable {
// the rest of your implementation here
}
func ==(lhs: ScriptRunner, rhs: ScriptRunner) -> Bool {
return ... // change this to whatever test that satisfies that lhs and rhs are equal
}
I needed an explicit cast like this:
@NSManaged private var storage: [String]
private var objects: Set<String>?
func remove(element:String) {
initSetIfNeeded()
if(objects!.contains(element)) {
objects!.remove(element)
storage = storage.filter({($0 as NSObject) !== (element as NSObject)}) // Explicit cast here!!
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With