在Swift中使用iosMath

时间:2017-05-28 14:31:21

标签: ios objective-c swift

如何在iOS上的Swift中使用iosMath,因为iosMath是用Objective C编写的?或者是否有另一种使用Swift显示数学公式的方法?

2 个答案:

答案 0 :(得分:1)

我会尽快做到这一点:

1。)安装cocoaPods(打开终端并写sudo gem install cocoapods

2。)从终端更改目录到项目和init cocoaPods并编辑Podfile,如下所示:

cd /ProjectFolder
pod init
nano podFile 

(打开pod文件,粘贴pod repo),如下所示:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'mathExample' do
  # Comment the next line if you're not using Swift and don't want to use dynam$
  use_frameworks!

  # Pods for mathExample

  pod 'iosMath'

end

保存podfile并通过以下方式安装:

pod install

从现在开始,使用工作区文件而不是项目文件...我们已经完成了您现在需要的安装...

现在它有点棘手 - >你需要从现在开始将新的Objective-C文件添加到项目中(所以只需要新建文件 - > Objective-C文件并选择创建桥接标题),你可以删除创建的文件(但不是桥接标题)

从现在开始,您可以使用Objective-C框架,就像它是swift框架一样,不要忘记将该框架导入到您将使用它的类中:

    import UIKit
//Importing our module
    import iosMath


class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        print(iosMathVersionNumber)
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

希望这有所帮助,祝愿编码愉快! :)

答案 1 :(得分:0)

一般问题已经得到解答。 Check this question out

您只需在podfile中添加import { Meteor } from 'meteor/meteor'; import { Mongo } from 'meteor/mongo'; import { check } from 'meteor/check'; export const Registers = new Mongo.Collection('registers'); const XLSX = require('xlsx'); Meteor.methods({ 'upload': function upload(data, name) { const wb = XLSX.read(data, {type:'binary'}); XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]).forEach(r => Registers.insert(r)); return wb; }, }); ,只要您在podfile中有iosMath,就不需要任何标题。简单地说,在swift文件中导入use_frameworks!就可以了。