Thursday, January 15, 2026
HomeiOS Development"Anticipated '}' at school" No Matter what Is strive

"Anticipated ‘}’ at school" No Matter what Is strive

[ad_1]

My code is beneath together with a photograph of the error I’m recieving. I’ve tried to position these "{" in any approach potential to no luck. I’ve additionally modified my code for CellForItemAt to be Else If statements and that additionally as you may see didn’t work.

I’m at a loss – I’ve additionally tried to rearrange the CellForItemAt however the finish consequence nonetheless brings up that I want so as to add "{" someplace. The code you see is the closest I used to be in a position to get to no errors. Any assistance is appreciated.

//  ViewController.swift
//  TwoCVs
//

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        tremendous.viewDidLoad()
        // Do any further setup after loading the view.
    }


}

class FirstCollectionViewCell: UICollectionViewCell {
    
    @IBOutlet weak var buttonOne: UIButton!
    
    override func awakeFromNib() {
        tremendous.awakeFromNib()
        commonInit()
    }
    func commonInit() {
        buttonOne.titleLabel!.font = UIFont(title: "Marker Felt", measurement: 20)
        buttonOne.layer.cornerRadius = 10
        buttonOne.clipsToBounds = true
        buttonOne.layer.borderWidth = 1.0
        buttonOne.layer.borderColor = UIColor.white.cgColor

class SecondCollectionViewCell: UICollectionViewCell {

    @IBOutlet weak var buttonTwo: UIButton!
    override func awakeFromNib() {
        tremendous.awakeFromNib()
        commonInit()
    }
    func commonInit() {
        buttonTwo.titleLabel!.font = UIFont(title: "Marker Felt", measurement: 20)
        buttonTwo.layer.cornerRadius = 10
        buttonTwo.clipsToBounds = true
        buttonTwo.layer.borderWidth = 1.0
        buttonTwo.layer.borderColor = UIColor.white.cgColor
    }
}

class ThirdCollectionViewCell: UICollectionViewCell {

    @IBOutlet weak var buttonThree: UIButton!
    override func awakeFromNib() {
        tremendous.awakeFromNib()
        commonInit()
    }
    func commonInit() {
        buttonThree.titleLabel!.font = UIFont(title: "Marker Felt", measurement: 20)
        buttonThree.layer.cornerRadius = 10
        buttonThree.clipsToBounds = true
        buttonThree.layer.borderWidth = 1.0
        buttonThree.layer.borderColor = UIColor.white.cgColor

class TwoCollectionsViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {
    @IBOutlet weak var firstCV: UICollectionView!
    @IBOutlet weak var secondCV: UICollectionView!
    @IBOutlet weak var thirdCV: UICollectionView!
    @IBAction func Buttons(_ sender: Any) {
        if let btn = sender as? UIButton {
            print(btn.restorationIdentifier!)
                guard let button = sender as? UIButton else { return }
                guard let id = Int(button.restorationIdentifier!) else {return}
            if id == 0 {
                performSegue(withIdentifier: "Good Work", sender: btn)
            }
            else if id == 1 {
                performSegue(withIdentifier: "Good Attempt", sender: btn)
            }
            else if id == 6 {
                performSegue(withIdentifier: "Second 1", sender: btn)
            }
        }
    }
    
    let firstData: [String] = [
        "Good Work", "Nice Try", "Btn 3", "Btn 4", "Btn 5", "Btn 6"
    ]

    let secondData: [String] = [
        "Second 1", "Second 2", "Second 3", "Second 4", "Second 5", "Second 6", "Second 7"
    ]
    let thirdData:  [String] = [
    "Action 1", "Action 2", "Action 3", "Action 4", "Action 5", "Action 6"]

    
    override func viewDidLoad() {
        tremendous.viewDidLoad()
        
        firstCV.dataSource = self
        firstCV.delegate = self
        
        secondCV.dataSource = self
        secondCV.delegate = self
        
        thirdCV.dataSource = self
        thirdCV.delegate = self
    }
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection part: Int) -> Int {
        // if it is the First Assortment View
        if collectionView == firstCV {
            return firstData.depend
            
        // it is not the First Assortment View, so it is the Second one
        return secondData.depend

        }
        return thirdData.depend
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        
        if collectionView == firstCV {
            let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "firstCell", for: indexPath) as! FirstCollectionViewCell
            cell.buttonOne.setTitle(firstData[indexPath.item], for: []) //permits for button title change in code above
            cell.buttonOne.restorationIdentifier = "(indexPath.row)"
            return cell
        } else if collectionView == secondCV {
                // it is not the First Assortment View, so it is the Second one
            let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "secondCell", for: indexPath) as! SecondCollectionViewCell
            cell.buttonTwo.setTitle(secondData[indexPath.item], for: [])
            cell.buttonTwo.restorationIdentifier = "(indexPath.row + firstData.depend)"
            return cell
        } else if collectionView == thirdCV {
            let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "thirdCell", for: indexPath) as! ThirdCollectionViewCell
            cell.buttonThree.setTitle(thirdData[indexPath.item], for: [])
            cell.buttonThree.restorationIdentifier = "(indexPath.row + secondData.depend)"
            return cell
        }




[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments