Please someone help me. I have been stuck for over a week trying to fix these errors, searching all over but with no success.
I am sorry if this is an easy fix but I really have wasted so much time adding and changing stuff but to no avail. Any help will be extremely appreciated :)
//Update: Added complete code for Userviewcontroller, also thank you so much for replies I am so thankful :)
import UIKit
import Parse
class UserTableViewController: UITableViewController {
var users = [""]
var following = [Bool]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
println(PFUser.currentUser())
var query = PFUser.query()
query!.findObjectsInBackgroundWithBlock({ (objects: [AnyObject]!, error: NSError!) -> Void in
self.users.removeAll(keepCapacity: true)
for object in objects {
var user:PFUser = object as! PFUser
var isFollowing:Bool
if user.username != PFUser.currentUser().username {
self.users.append(user.username)
isFollowing = false
var query = PFQuery(className:"followers")
query.whereKey("follower", equalTo:PFUser.currentUser().username)
query.whereKey("following", equalTo:user.username)
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]!, error: NSError!) -> Void in
if error == nil {
for object in objects {
isFollowing = true
}
self.following.append(isFollowing)
self.tableView.reloadData()
} else {
// Log details of the failure
println(error)
}
}
}
}
})
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
println(following)
return users.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell:UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as! UITableViewCell
if following.count > indexPath.row {
if following[indexPath.row] == true {
cell.accessoryType = UITableViewCellAccessoryType.Checkmark
}
}
cell.textLabel?.text = users[indexPath.row]
return cell
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
var cell:UITableViewCell = tableView.cellForRowAtIndexPath(indexPath)!
if cell.accessoryType == UITableViewCellAccessoryType.Checkmark {
cell.accessoryType = UITableViewCellAccessoryType.None
var query = PFQuery(className:"followers")
query.whereKey("follower", equalTo:PFUser.currentUser()!.username!)
query.whereKey("following", equalTo:cell.textLabel!.text!)
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]!, error: NSError!) -> Void in
if error == nil {
for object in objects {
object.deleteInBackground()
}
} else {
// Log details of the failure
println(error)
}
}
} else {
cell.accessoryType = UITableViewCellAccessoryType.Checkmark
var following = PFObject(className: "followers")
following["following"] = cell.textLabel?.text
following["follower"] = PFUser.currentUser()!.username
following.saveInBackground()
}
}
}
//I am getting the ":
Cannot invoke 'findObjectsInBackgroundWithBlock' with an argument list of type '(([AnyObject]!, NSError!) -> Void)"
error I have tried every suggested solution and code change on stack overflow this is driving me crazy please help. Also I am getting this same thing on another line :(
I have attempted to switch the ! to ? pretty much everything you could think of. I am guessing it is an easy fix.
I will be extremely grateful for a fix