我有一个typedef:
typedef NSString VMVideoCategoryType;
extern VMVideoCategoryType *const VMVideoCategoryType_MusicVideo;
extern VMVideoCategoryType *const VMVideoCategoryType_Audio;
extern VMVideoCategoryType *const VMVideoCategoryType_Performance;
extern VMVideoCategoryType *const VMVideoCategoryType_Lyric;
extern VMVideoCategoryType *const VMVideoCategoryType_Show;
我已经将此文件包含在桥接头文件中。但是,当我尝试访问VMVideoCategoryType
Swift文件时,出现错误:
Use of undeclared type 'VMVideoCategoryType'
有什么办法可以使这项工作,还是我必须在Swift中完全重新定义此类型?
我有点推测,但是原因似乎是NSString
不能静态分配像Objective-C这样的对象(请参阅例如,是否在堆栈上创建了Objective-C中的对象?)。如果
typedef NSString VMVideoCategoryType;
被导入到Swift中,然后您可以声明一个局部变量
var foo : VMVideoCategoryType
这将是,NSString
而不是的指针NSString
。
还要注意,您在Swift中看到的NSString
对应NSString *
于Objective-C。
如果定义VMVideoCategoryType
为一个typedef的NSString *
则是在斯威夫特可见:
typedef NSString * VMVideoCategoryType;
extern VMVideoCategoryType const VMVideoCategoryType_MusicVideo;
// ...
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句