Ios 将数组从解析获取到表视图(Swift 2)

Ios 将数组从解析获取到表视图(Swift 2),ios,swift,parse-platform,Ios,Swift,Parse Platform,我试图从Parse中“User”类中的“my_class”中提取中的字符串数组。我希望在点击搜索按钮时,数组中的每个字符串都成为tableview中的一个单独单元格。这是我在“我的课程”中的数组:[“物理学”、“经济学”、“微积分预科”]。我希望“物理学”是它自己的细胞,“经济学”是它自己的细胞,等等 谢谢 试试下面的方法 编辑 var songsArray = [String]() func fetchUsers() { let userQuery: PFQuery = PFUser

我试图从Parse中“User”类中的“my_class”中提取中的字符串数组。我希望在点击搜索按钮时,数组中的每个字符串都成为tableview中的一个单独单元格。这是我在“我的课程”中的数组:[“物理学”、“经济学”、“微积分预科”]。我希望“物理学”是它自己的细胞,“经济学”是它自己的细胞,等等



谢谢

试试下面的方法

编辑

 var songsArray = [String]()

 func fetchUsers() {
let userQuery: PFQuery = PFUser.query()!

//search users by the sepcified username, returns a users! object
//make an array to put the values from the users! array object into
//then append those from your "middle-man" array into your destination array,     
//in this example songArray is destination array and songsFromParse is "middle-man" array

userQuery.whereKey("username", equalTo: (username)!)
userQuery.findObjectsInBackgroundWithBlock({
    (users, error) -> Void in

    var songsFromParse = users!

    if error == nil {
        if songsFromParse.count != 0 {

      self.songsArray = (songsFromParse[i].valueForKey("CurrentSongURLArray") as! Array)
            }


        self.tableView.reloadData()
    } else {
        print(error)
    }
 })
}
然后获取包含检索到的对象的新数组(在本例中为
songsArray
),并使用它填充tableView。在CellForRowatineXpath中

 override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

let cell = tableView.dequeueReusableCellWithIdentifier("Cell ID")
cell?.textLabel?.text = songsArray[indexPath]
return cell!
}

p、 s如果这对您有效,请勾选并接受答案:)看起来您正在尝试从每个用户处获取歌曲查询。我试图从一个用户的“my_类”中提取字符串数组。哦,好的,我明白了,我刚刚编辑了我的答案。现在,您可以通过指定的
用户名
进行搜索,然后通过指定其
值forkey
来检索所需的
[Array]
,该值是您在Parse中命名的列
 override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

let cell = tableView.dequeueReusableCellWithIdentifier("Cell ID")
cell?.textLabel?.text = songsArray[indexPath]
return cell!
}