无法为“MCNearbyServiceAdvertiser”类型调用初始值设定项

时间:2015-09-21 10:05:13

标签: ios swift

在更新到Swift 2.0之后,使用iOS多重连接,遇到以下代码问题:

var advertiser:MCNearbyServiceAdvertiser!
var peer:MCPeerID!

func startEndAdvertising(value:Bool)
{
     if advertiser == nil
     {
         var someObject: [String : AnyObject] = ["profileName" : DataCentral.getInstance.userPeerVO.peerName]
         advertiser = MCNearbyServiceAdvertiser(peer: peer, discoveryInfo: someObject, serviceType: "shadow-chat")
         advertiser.delegate = self
     }
 }

以下行生成错误为“无法使用类型'的参数列表调用类型'MCNearbyServiceAdvertiser'的初始化者'(peer:MCPeerID!,discoveryInfo:[String:AnyObject],serviceType:String)'”

advertiser = MCNearbyServiceAdvertiser(peer: peer, discoveryInfo: someObject, serviceType: "shadow-chat")

0 个答案:

没有答案