[CKRecord stringForKey:]: unrecognized selector sent to instance 0x17412ece0'
I am getting the above error, and not sure what I need to do to correct it. I am running a query to return CKAssets into a collection view to show pictures. I want two text fields to match up, and when they do for the image associated to populate the view. Does anyone have any suggestions?
@IBOutlet var myCollectionView: UICollectionView!
let reuseIdentifier = "MyCell"
var matchedSelfie = [String]()
override func viewDidLoad() {
super.viewDidLoad()
let database = CKContainer.defaultContainer().publicCloudDatabase
let container = CKContainer.defaultContainer()
let publicDB = container.publicCloudDatabase
let data = CKRecord(recordType: "theUsers")
let text1 = data.valueForKey("text1")
let text2 = data.valueForKey("text2")
var predicate = NSPredicate(value: text1 === text2)
let myQuery = CKQuery(recordType: "theUsers", predicate: predicate)
var mySelfie = matchedSelfie
publicDB.performQuery(myQuery, inZoneWithID: nil) {
results, error in
if error != nil {
println(error)
} else {
for record in results{
if let aselfie = record.stringForKey("selfie") { //Optional binding
mySelfie.append(aselfie) //Append to string array
mySelfie.append(aselfie)
return ()
}
}}}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
//#warning Incomplete method implementation -- Return the number of sections
return 1
}
override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
//#warning Incomplete method implementation -- Return the number of items in the section
return matchedSelfie.count
}
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = myCollectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as CollectionViewCell
let image = UIImage(named: matchedSelfie[indexPath.row])
cell.matchedSelfie.image = image
// Configure the cell
return cell
}