winston
winston

Reputation: 3100

UICollectionView does not have a member named dequeueResuableCellWithReuseIdentifier

I'm getting an interesting error in XCode 6:

UICollectionView does not have a member named dequeueResuableCellWithReuseIdentifier

The error appears on the second line ("let cell...") in the following function:

override func collectionView(collectionView: UICollectionView?, cellForItemAtIndexPath indexPath: NSIndexPath?) -> UICollectionViewCell {
        // Configure the cell

        let cell:FightCollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as FightCollectionViewCell
        let battle = self.lobbyData.objectAtIndex(indexPath!.row) as PFUser

        PFCloud.callFunctionInBackground("getOnlineUsers", withParameters: [:], target: nil, selector: "block:")

            func block(users: NSArray, error:NSError!){
                if(error == nil){

                    let user:PFUser = (users as NSArray).lastObject as PFUser
                    let avatarObject = user["avatar"] as PFObject!

                    avatarObject.fetchInBackgroundWithBlock {
                        (object: PFObject!, error: NSError!) in
                        if error == nil {
                            let imageFile = object["image"] as PFFile
                            imageFile.getDataInBackgroundWithBlock {
                                (imageData: NSData!, error: NSError!) -> Void in
                                if error == nil {
                                    let image = UIImage(data:imageData)
                                    cell.avatarImageView.image = image
                                }
                            }
                        }
                    }
                }
           }


        return cell
    }

This code did not throw an error in XCode 6 beta. Why does XCode now have an issue with that line of code? I'm new to iOS development so any help would be greatly appreciated.

Thanks!

Upvotes: 1

Views: 419

Answers (1)

Andrew
Andrew

Reputation: 2468

Judging by your method signature, my guess is that your error message is really UICollectionView? does not have a member named dequeueResuableCellWithReuseIdentifier.

UICollectionView? is a completely different type than UICollectionView. It's an optional, and it definitely does not have the same methods defined on it as UICollectionView!

Looking at the API, that delegate method isn't defined to take optionals. Try removing the ?s.

The reason is that the entirety of Cocoa APIs (a huge amount) have to be hand-checked for optional conformance, which is still an ongoing process. This leads to API changes between Xcode versions.

Upvotes: 2

Related Questions