I’m just trying to create a basic Dictionary using [NSObject:AnyObject] and I’m getting an “Unknown identifier” compiler error.
Use Object
, not NSObject. The latter is a cocoa class and does not exist on .NET. "Object” maps the the appropriate root class on each platform.
OK. Thanks.
Would it be possible to simply map NSObject to Object in the compiler? Just trying to minimize code differences between regular swift and silver swift.
Typealias seems to be a good workaround as well.
typealias NSObject = Object
We could probably do that in the base lib. Does Apple Swift not support Object?
It’d be nice in the base lib. Otherwise, I’m thinking I’d need some sort of silver-only header file where I typealias a bunch of stuff.
There’s no Object in swift or objective-c. There’s NSObject from objective-c. In swift, you can now declare a class with no ancestor it.
Screen cap from a playground attempting to reference ‘Object’
import Cocoa
var y: NSObject
var x: Object // Use of undeclared type ‘Object’
I’ve added the bias in the base lib, for the next version. Swift.NSObject will be defined for all three platforms, paining to System.Object, java.lang.Object and Foundation.NSObject, respectively.
Note that in Silver, any class will descend from Object, whether you provide an ancestor or not. That difference should be largely ignorable.
Once difference it causes with swift using xcode is that init is not declared with the override keyword and you cannot call super.init.