Php Can';t检索数据并在iOS应用程序中显示

Php Can';t检索数据并在iOS应用程序中显示,php,ios,swift,xcode,Php,Ios,Swift,Xcode,我正在尝试从数据库中检索简单的文本数据。当应用程序运行时,你输入你想要的任何内容,它会将其保存到数据库中。那部分正在发挥作用。当我登录到phpMyAdmin时,数据就在那里。然而,我也试图显示数据,就在用户输入文本的文本字段上方。当应用程序运行时,那里什么都没有。这是我的检索数据函数的代码。多谢各位 func retrieveMessages(latestMessage:String) { // Specify the URL of our retrieval web service let

我正在尝试从数据库中检索简单的文本数据。当应用程序运行时,你输入你想要的任何内容,它会将其保存到数据库中。那部分正在发挥作用。当我登录到phpMyAdmin时,数据就在那里。然而,我也试图显示数据,就在用户输入文本的文本字段上方。当应用程序运行时,那里什么都没有。这是我的检索数据函数的代码。多谢各位

func retrieveMessages(latestMessage:String) {

// Specify the URL of our retrieval web service
let url:NSURL = NSURL(string: "http://mypage.com/index.php")!

// Create a NSURLSession task with completion handler
let task:NSURLSessionDataTask = NSURLSession.sharedSession().dataTaskWithURL(url, completionHandler: { (data:NSData?, response:NSURLResponse?, error:NSError?) -> Void in


    do {
        // Convert the json data into an array
        let dataArray:[AnyObject] = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers) as! [AnyObject]

        // Clear the messages array
        self.messagesArray.removeAll(keepCapacity: false)

        // Loop through each dictionary in the array
        for data in dataArray {

            let dictionary:[String:String] = data as! [String:String]

            // Append it to our messages array
            if dictionary["Text"] != nil {
                self.messagesArray.append(dictionary["Text"]!)
            }
        }

        dispatch_async(dispatch_get_main_queue()) {

            // Refresh the table
            self.tableView.reloadData()
        }
    }
    catch{}

})

// Run the task
task.resume()

}

是否已使用ViewController设置tableView的委托和数据源。是否接收任何类型的数据?请尝试打印
数据
,也可以在
catch{}
块中添加一个
prin()
。@Dravidian我在应用程序运行时接收数据并输入数据。它填充数据库,当我在浏览器中键入url时,数据就在那里并正确提取。我会说在catch块中打印(数据)?编辑最后的评论…。我的意思是我在数据库中接收数据,而不是在我的应用程序本身中。运行应用程序时没有显示任何数据。您是否使用ViewController设置了tableView的委托和数据源。是否接收任何类型的数据?请尝试打印
数据
,也可以在
catch{}
块中添加一个
prin()
。@Dravidian我在应用程序运行时接收数据并输入数据。它填充数据库,当我在浏览器中键入url时,数据就在那里并正确提取。我会说在catch块中打印(数据)?编辑最后的评论…。我的意思是我在数据库中接收数据,而不是在我的应用程序本身中。运行应用程序时没有显示任何数据