0

I have a PFObject ("Task") which contains keys ("taskCreatorEmail") of type string, and ("taskAssignedTo") of type array. ("taskAssignedTo") stores an array of objects. The objects consists of "name" and "email" key/value pairs.

How can I retrieve all unique Assignee "name" values created by a specified creator?

Note: I'm using PFQueryTableViewController, so the query I use to retrieve data is:

func baseQuery() -> PFQuery {
    var query = PFQuery(className: "Task")
    let userDetails = Authentication().getUserDetails()
    query.whereKey("taskCreatorEmail", equalTo: userDetails.email)
    query.orderByAscending("updatedAt")

    return query
}

The goal is to populate the tableView cells with the Assignee Names.

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject?) -> PFTableViewCell? {
    var cell = tableView.dequeueReusableCellWithIdentifier("TaskGroupsCell") as! PFTableViewCell!
    if cell == nil {
        cell = PFTableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "TaskGroupsCell")
    }

    let assignees = object?["taskAssignedTo"] as! NSArray
    for object in assignees {

    }

    return cell
}
Eugene Teh
  • 263
  • 2
  • 3
  • 12
  • Why are you storing the data in an array, why aren't you using a relationship? – Wain Sep 07 '15 at 14:12
  • @Wain Because I feel a relationship is not effective in my current implementation. It would be rare to have more than 1 assignee, and if we were to delete tasks, it would result in having orphaned relations as well. Fetching data would also be a lot more efficient. Am open to suggestions on better ways to implement this though. – Eugene Teh Sep 08 '15 at 00:07

0 Answers0