如何在Swift中访问NSString常量(键)?

flo*_*ger 6 constants objective-c nsstring ios swift

在Objective-C中,我们都习惯于创建NSString常量来存储和访问NSDictionaries中的信息,或者用于NSNotifications的唯一名称.

// in MYClass.h
FOUNDATION_EXTERN NSString * const kMYNotificationName;

// in MYClass.m
NSString * const kMYNotificationName = @"my.app.notification";

[[NSNotificationCenter defaultCenter] postNotificationName:kMYNotificationName object:self userInfo:nil];
Run Code Online (Sandbox Code Playgroud)

现在,使用Xcode 6的混合和匹配我想在Swift类中注册这个特定的NSNotification:

NSNotificationCenter.defaultCenter()
                    .addObserver(self, 
                                 selector:"notificationReceived:", 
                                 name:kMYNotificationName, 
                                 object:nil)
Run Code Online (Sandbox Code Playgroud)

编译错误是"使用未解析的标识符'kMYNotificationName'",我无能为力.

我已经检查过的低调水果是:

  • Objective-C头文件包含在Bridging-Header中
  • 在加载swift Header之前包含Bridging-Header(常量不是类型但是谁知道)

有什么可以指点我的吗?除了"直接使用字符串"之外的任何变通方法?

非常感谢,弗洛