使用Swift的iOS上的XMPP连接问题

我正在尝试使用Swift使用XMPP框架( https://github.com/robbiehanson/XMPPFramework )。 我是新来的迅速

class ViewController: UIViewController { var password: NSString? var isOpen: Bool = false var xstream: XMPPStream? var loginServer: String = "" override func viewDidLoad() { super.viewDidLoad() println(connect()) // 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. } func connect() ->Bool{ var xstream = XMPPStream() var error: NSError? xstream.addDelegate(self, delegateQueue: dispatch_get_main_queue()) xstream.myJID = XMPPJID.jidWithString("test@localhost") xstream.hostName="127.0.0.1" xstream.hostPort=5222 var password = "testing" if !xstream.connectWithTimeout(XMPPStreamTimeoutNone, error: &error) { println(error) } println(xstream.isConnecting()) // This prints true return xstream.isConnected();// This prints false. } } 

用户名和密码和服务器的细节是正确的,因为我使用adium连接到服务器,它工作正常。

记住连接需要几秒钟才能build立。 使用其他委托方法来跟踪连接的状态。