1

In Xcode 6 Beta 6,

I am unable to use any NSFontManager methods in Swift. For example:

var fontManager = NSFontManager.sharedFontManager()

fontManager.setAction("changeFont:")

I always get the error: NSFontManager does not have a member named setAction

This occurs for any method (e.g. setDelegate, setTarget)

Thanks for any help.

vacawama
  • 150,663
  • 30
  • 266
  • 294
Fran
  • 15
  • 2

1 Answers1

2

Try this:

fontManager.action = Selector("changeFont:")

Properties are set using the property syntax in Swift.

In ObjC, properties were declared with (if not using @property):

- (X) myProp { return ... }
- (void) setMyProp(X value) { ... }

In Swift, the property declarations look more like C#:

var myProp : X { get { return ... } set { ... } }

So you can't call the setter explicitly using the same method name as in ObjC (though I have actually no idea what it will be compiled into...).

Krumelur
  • 31,081
  • 7
  • 77
  • 119