如何将 DDMathParser 与 Objective-C 一起使用?

How do I use DDMathParser with Objective-C?

我想将 DDMathParser 库与 Objective-C 一起使用,但它是用 Swift 编写的。到目前为止,这是我尝试过的方法:

#import <MathParser/MathParser.h>

// ...

// This throws error:
Expression *e;

这不会生成,因为编译器找不到 DDMathParser 声明的 "Expression" 类型。我还尝试将导入语句切换为:

#import <MathParser/MathParser-Swift.h>

但还是没有运气。

我无法在 Objective-C 中找到任何使用此库的在线示例。我是 Objective-C 的新手,所以我什至不知道要使用什么导入语句;也许其他人发现了这个常识?

DDMathParser 的 Swift 版本并不是为了从 Objective-C 开始可用而编写的;它被写成 Swift-like.

如果您需要使用Objective-C中的DDMathParser,我建议使用objc标签处的代码;这是 Objective-C 代码的最新版本:https://github.com/davedelong/DDMathParser/releases/tag/objc