OGeek|极客世界-中国程序员成长平台

标题: ios - #import "Project-Swift.h"出现了一些奇怪的问题 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 18:12
标题: ios - #import "Project-Swift.h"出现了一些奇怪的问题

项目与 ocswift 混合使用。

#import "myProjectName-Swift.h"AppDelegate.m,:

Project是我自己创建的Objective-c语言,几乎用swift语言编写。并且在 Appdelegate.m 我想使用 swift 的类,所以

但是很遗憾,我的项目在myProjectName-Swift.h中出现了一些error:

代码如下:

SWIFT_CLASS_PROPERTY(@property (nonatomic, class, readonly, copy) 
NSString * _Nonnull ;)

+ (NSString * _Nonnull);
SWIFT_CLASS_PROPERTY(@property (nonatomic, class, readonly, copy) 
NSString * _Nonnull ;)

+ (NSString * _Nonnull);

SWIFT_CLASS_PROPERTY(@property (nonatomic, class, readonly, strong) UIColor * _Nonnull APP_COLOR;)

+ (UIColor * _Nonnull)APP_COLOR;

错误是:

Expected ';' at end of declaration list.

cannot declare variable inside @interface or @protocal

Expected member name or ';' after declaration specifiers

Expected ']'

Property requires fields to be named

Missing '[' at start of message send expression

等等……


注意
在全局 swift 中,我设置了这样的汉字变量:

class Global: NSObject {

}

编辑 - 1

因为我觉得static let "有错误点,所以我注释了这行,项目不会显示这个error。或者我删除,`,也不会显示错误。



Best Answer-推荐答案


Objective-C 不支持标识符(变量名、类名、方法名等)中的 Unicode,仅支持字符串文字(“




欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4