我无法在我的应用程序中使用委托

时间:2015-12-25 04:38:46

标签: ios swift frameworks delegates

首先我制作一个关于蓝牙的SDK

ImyBluetoothManager.swift

public protocol ImyBluetoothManager: NSObjectProtocol {

  var delegate: myBluetoothDelegate?{get set}
}

public class myBluetooth {

  public static func getManager() -> ImyBluetoothManager? {

   return myBluetoothManager.sharedInstance()
  }
}

myBluetoothManager.swift

class myBluetoothManager: NSObject, CBCentralManagerDelegate, CBPeripheralDelegate, myBluetoothManager {

  static var instance: myBluetoothManager!

  var delegate: myBluetoothDelegate? {
    get {
      return delegate
    }
    set {
      delegate = newValue
    }
  }

  private override init() {}

  static func sharedInstance() ->myBluetoothManager {

    if self.instance == nil {

      self.instance = myBluetoothManager()
      self.instance.setup()
      self.instance.scanBLE()
    }     

    return self.instance
  }

然后我运行它并获得myBluetooth.framework,我新建了一个项目'ExampleApp'

ExampleApp中

ViewController.swift

import myBluetooth

class ViewController: UIViewController,myBluetoothDelegate {

  override func viewDidLoad() {

    let test = SiltaBluetooth.getManager()
    test?.delegate = self

    super.viewDidLoad()
  }
}

然后我运行ExampleApp,并警告我。

  

警告:无法加载任何Objective-C类信息。这将   显着降低了可用类型信息的质量。

0 个答案:

没有答案