【发布时间】:2014-12-08 19:11:08
【问题描述】:
我无法从 Swift 访问使用 Mogenerator 生成的 c-struct。
结构在实现中:
const struct MyAttributes MyAttributes = {
.foo = @"foo",
};
然后在标题中:
extern const struct MyAttributes {
__unsafe_unretained NSString *foo;
} MyAttributes;
我将标题导入添加到桥接头。但我无法从 Swift 访问结构。使用 Objective C 我可以。我想也许 Swift 需要结构声明,因为它在实现文件中,所以我尝试将 .m 文件添加到桥接头,但这不起作用。我认为我无法更改这些文件的结构,因为它们是由 Mogenerator 生成的。
我该如何解决这个问题?
谢谢。
【问题讨论】:
-
或者在 mogenerater 中使用 swift 标志。那么就不需要任何桥接了。
-
我的大部分代码仍在 Objective C 中。
标签: ios swift mogenerator