我正在尝试使用 Swift 来实现 Microsoft Band SDK。尝试设置我的代码时,我不断收到此错误。
class ViewController: UIViewController, UITableViewDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate, MSBClientManagerDelegate, UIScrollViewDelegate {
我以前从未见过这种情况,但我也从未尝试将 Objective C 示例转换为 Swift。
任何帮助,将不胜感激!
编辑:这是来自 Objective C 的协议
@protocol MSBClientManagerDelegate<NSObject>
- (void)clientManager:(MSBClientManager *)clientManager clientDidConnect:(MSBClient *)client;
- (void)clientManager:(MSBClientManager *)clientManager clientDidDisconnect:(MSBClient *)client;
- (void)clientManager:(MSBClientManager *)clientManager client:(MSBClient *)client didFailToConnectWithError:(NSError *)error;
@end
编辑 2:使用建议的 Swift Helper 类后
这就是我尝试建立连接的方式。
var clients:NSArray = bandHelper.attachedClients()!
var firstClient: MSBClient = clients[0] as MSBClient
if (clients.count == 0){
println("The band is not detected")
return
}
我不知道应该如何设置
bandHelper.connectClient(firstClient, {completion: (connected:true -> void in)})
println("Please wait...connecting to band")
然后,当尝试向乐队发送照片时,此功能不起作用
bandHelper.client?.personalizationManager.updateMeTileImage(bandScaledImage, { (completionHandler: NSError!) -> Void in
NSLog("%@", NSError())})
我被使用助手类抛弃了。任何帮助,将不胜感激!