将新字符串从objective-c返回给swift时字符串损坏

将新字符串从objective-c返回给swift时字符串损坏,objective-c,string,swift,nsstring,corruption,Objective C,String,Swift,Nsstring,Corruption,我尝试从Objective-C中的枚举构建字符串: + (NSString *)getStringFromKey:(ITGenericNotification)key { return [NSString stringWithFormat:@"notification%lu", (long)key]; } 这段代码在一年多的时间里运行得非常好 但是,当我尝试从swift呼叫时: let notificationKey = NSNotification.getStringFromKey(

我尝试从Objective-C中的枚举构建字符串:

+ (NSString *)getStringFromKey:(ITGenericNotification)key {
    return [NSString stringWithFormat:@"notification%lu", (long)key];
}
这段代码在一年多的时间里运行得非常好

但是,当我尝试从swift呼叫时:

let notificationKey = NSNotification.getStringFromKey(ITNotificationWithObject.DidChangedQuestion.hashValue)
我得到一个损坏的字符串:

发生了什么事? ITGenericNotification的值似乎是正确的

ITGenericNotification
定义为
typedef long ITGenericNotification并用作带有
typedef NS_enum(ITGenericNotification,ITNotificationWithObject)的枚举的基类型


+(NSString*)getStringFromKey:(ITGenericNotification)key
作为
NSNotification
的一个类别实现,您可能希望
.rawValue
,而不是
.hashValue
,来获取底层 枚举的整数值

(此外,“调试器变量”视图有时是错误的。如果有疑问, 向代码中添加
println()
NSLog()
,以验证
你的变量。)

事实上,我被自动完成中显示的类型误导了。