Tag: mogenerator

Mogenerator和ARC在XCode 4.6

我刚刚开始将mogenerator与核心数据集成到一个应用程序项目中,按照最佳实践推荐。 我添加了以下构build脚本,并带有一个标志来支持ARC。 mogenerator -m FavesDataModel.xcdatamodeld/FavesDataModel.xcdatamodel –template-var arc=true 该脚本成功地构build了所有必需的类和子类。 那时候,我把所有生成的文件复制到我的项目中。 最初,我得到了一个干净的成功构build。 但是,当尝试另一个生成(不作任何更改)时,会出现以下ARC错误: ARC forbids Objective-C objects in structs or unions 在用下划线生成的文件中发生错误。 有趣的是,当构build脚本构build文件如下所示: extern const struct FavoriteAttributes { __unsafe_unretained NSString *maxCFS; __unsafe_unretained NSString *maxFeet; __unsafe_unretained NSString *minCFS; __unsafe_unretained NSString *minFeet; __unsafe_unretained NSString *stationIdentifier; __unsafe_unretained NSString *stationRealName; __unsafe_unretained NSString *stationState; } FavoriteAttributes; 但是,在成功构build之后,XCode将删除__unsafe_unretained属性。 使用mogenerator与ARC打开有已知的问题? 任何想法的解决scheme或解决方法? 谢谢! V

从Swift访问extern const struct

我无法从Swift中使用Mogenerator生成的c-struct。 该结构在实现中: const struct MyAttributes MyAttributes = { .foo = @"foo", }; 然后在标题中: extern const struct MyAttributes { __unsafe_unretained NSString *foo; } MyAttributes; 我将头导入添加到桥头。 但是我不能从Swift访问结构。 用Objective CI可以。 我想也许Swift需要结构声明,因为它是在实现文件中,所以我试图将.m文件添加到桥接头,但这是行不通的。 我想我不能改变这些文件的结构,因为它们是由Mogenerator生成的。 我该如何解决? 谢谢。