私は、ユーザーの複数の選択をtableviewから比較し、それらをParseデータベースと比較しようとしています。だから私の問題は2倍です1.私の現在のコードはそれについて正しい方法で行くのですか? 2.値型Boolを引数型PFObjectに変換するにはどうすればよいですか?Swift: '() - > Bool'型の値を 'PFObject'の予想される引数型に変換できません
Cannot convert value of type '() -> Bool' to expected argument type 'PFObject'
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showResults" {
// Get reference to destination view controller
let destination = segue.destinationViewController as! CollectionViewController
if let selectedItem = tableView.indexPathsForSelectedRows{
for var i = 0; i < selectedItem.count; ++i {
var currentPath = selectedItem[i] as NSIndexPath
var cell = tableView.cellForRowAtIndexPath(currentPath)
if let cell = cell {
//add major(s) selected to data variable in collectionview as type text(String)
destination.data.append(cell.textLabel!.text!)
}
imagesQuery = PFQuery(クラス名: "CollegeImages")させ imagesQuery.selectKeys([ "名前"]) imagesQuery.findObjectsInBackgroundWithBlock({(オブジェクト:[PFObject]? 、エラー:NSError?)エラーの場合は == nil { return returned objects = objects { //オブジェクト配列がnilではない //各オブジェクトを取得するために配列をループしますオブジェクトが返されたオブジェクト{ (object ["name"] as! String)を }}
}
})
let majorSelected:String = (cell?.textLabel!.text!)!
let query = PFQuery(className:"CollegeMajors")
query.selectKeys(["Major"])
query.findObjectsInBackgroundWithBlock ({
(objects: [PFObject]?, error: NSError?) in
if error == nil {
// The find succeeded.
print("Successfully retrieved \(objects!.count) majors.", terminator: "")
// Do something with the found objects
if let returnedobjects = objects {
if returnedobjects.contains ({($0["Major"] as? String)! == majorSelected}) && query.selectKeys(["College Name"]) == imagesQuery.selectKeys(["name"]) {
print("your in!") // transition to the new screen
}
else {
print("your out.") // do whatever
}
}
} else {
// Log details of the failure
print("Error: \(error!) \(error!.userInfo)", terminator: "")
}
})
}
}
}
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
//Keep track of which major(s) the user selected
let path = tableView.indexPathForSelectedRow!
if let cell = tableView.cellForRowAtIndexPath(indexPath){
//Trigger the segue to go to the collection view
self.performSegueWithIdentifier("showResults", sender: self)
}
}
'{...} 'の前後に'( 'と') 'を入れないでください – luk2302
ソースコードとエラーメッセージをテキストとして追加します。画像は検索できません。 –