Reputation: 27221
I can't translate this Objective-C code into Swift
NSRunLoop *runloop = [NSRunLoop currentRunLoop];
[runloop addPort:[NSMachPort port] forMode:NSDefaultRunLoopMode];
The problem is about [NSMachPort port]
. How it looks in Swift?
This code as shown as incorrect:
let runloop:NSRunLoop = NSRunLoop.currentRunLoop()
runloop.addPort(NSMachPort.port, forMode: NSDefaultRunLoopMode)
Neither NSMachPort.port
or NSMachPort.port()
are correct.
Does NSPort()
the same as [NSMachPort port]
?
Upvotes: 0
Views: 307
Reputation: 100632
NSMachPort
is a subclass of NSPort
rather than the latter being an improved name, so NSPort()
will not construct an NSMachPort
.
NSMachPort()
is the equivalent of [NSMachPort port]
.
Upvotes: 4