简体   繁体   English

初始化时使用Twilio iOS SDK错误

[英]Using Twilio iOS SDK error on initialization

Im tyring to use the Twilio iOS SDK with Swift and when I attempt to initialise a TCDevice Object I get the following error Cannot find an initializer for type 'TCDevice' that accepts an argument list of type '(capabilityToken: NSString?, delegate: nil)' 我想将Twilio iOS SDK与Swift一起使用,当我尝试初始化TCDevice对象时,出现以下错误: Cannot find an initializer for type 'TCDevice' that accepts an argument list of type '(capabilityToken: NSString?, delegate: nil)'

The code looks like this self.device = TCDevice(capabilityToken: token, delegate: nil) 代码看起来像如下self.device = TCDevice(capabilityToken: token, delegate: nil)

and the token is this var token = body as? NSString 这个令牌是var token = body as? NSString var token = body as? NSString

Any help would be great. 任何帮助都会很棒。

I don't know Twillo, but the only to things I could imagine are these... 我不知道Twillo,但是我能想到的唯一的就是这些...

Please try this: 请尝试以下方法:

self.device = TCDevice(capabilityToken: token!, delegate: self)

To give you the right answer I need the following... please type in your Xcode just this: 为了给您正确的答案,我需要以下内容...请输入您的Xcode:

self.device = TCDevice(

Than Xcode will autocomplete the initializer... Copy the Autocomplete and post it here... Than I could help you without guessing :-) 比Xcode可以自动完成初始化程序...复制自动完成并将其发布在这里...比我可以帮到您的多了:-)

Twilio evangelist here. Twilio的传播者在这里。

Pretty sure that the compiler is complaining about you trying to pass it an optional type for the capability token. 可以肯定的是,编译器在抱怨您试图将功能令牌的可选类型传递给它。 Try unwrapping the optional: 尝试展开可选的:

self.device = TCDevice(capabilityToken: token!, delegate: nil)

Also, check out these two blog posts I wrote on using the Twilio Client for iOS SDK with Swift: 另外,请查看我写的关于在Swift中使用Twilio Client for iOS SDK的这两篇博客文章:

https://www.twilio.com/blog/2015/02/a-swift-adventure-building-basicphone-with-twilioclient.html https://www.twilio.com/blog/2015/08/a-swift-adventure-building-basicphone-with-twilioclient-part-2.html https://www.twilio.com/blog/2015/02/a-swift-adventure-building-basicphone-with-twilioclient.html https://www.twilio.com/blog/2015/08/a-swift -adventure-building-basicphone-with-twilioclient-part-2.html

These posts were both written using Swift 1.1, so make sure you also reference the source in Github which has been updated to be compatible with Swift 2. Hope that helps. 这些帖子都是使用Swift 1.1编写的,因此请确保您还引用了Github中的源代码,该源代码已更新为与Swift 2兼容。希望有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM