manku
manku

Reputation: 13

inaccessible due to 'internal' protection level swift 3

I am getting this error "'removeCircleLabel' is inaccessible due to 'internal' protection level" on this line of code. I was adding CVCalendar Library to my project.I added the pod but i when i am adding the view controller code in my project that time its giving me this error.

@IBOutlet weak var calendarView: CVCalendarView!

  @IBAction func removeCircleAndDot(sender: AnyObject) {
    if let dayView = selectedDay {
        calendarView.contentController.removeCircleLabel(dayView)// **error on this line** 

        if dayView.date.day < randomNumberOfDotMarkersForDay.count {
            randomNumberOfDotMarkersForDay[dayView.date.day] = 0
        }

        calendarView.contentController.refreshPresentedMonth()
    }
}

 public typealias ContentViewController = CVCalendarContentViewController

 public final class CVCalendarView: UIView {
// MARK: - Public properties
public var manager: Manager!
public var appearance: Appearance!
public var touchController: TouchController!
public var coordinator: Coordinator!
public var animator: Animator!
public var contentController: ContentViewController!
public var calendarMode: CalendarMode!

public var (weekViewSize, dayViewSize): (CGSize?, CGSize?)
}


// MARK: Delete circle views (in effect refreshing the dayView circle)
extension CVCalendarContentViewController {
  func removeCircleLabel(_ dayView: CVCalendarDayView) {
    for each in dayView.subviews {
        if each is UILabel {
            continue
        } else if each is CVAuxiliaryView {
            continue
        } else {
            each.removeFromSuperview()
        }
    }
  }
}

MY View Controller Code

 import UIKit
 import CVCalendar


class MainPageViewController: UIViewController, UITableViewDelegate,     
UITableViewDataSource {

struct Color {
    static let selectedText = UIColor.white
    static let text = UIColor.black
    static let textDisabled = UIColor.gray
    static let selectionBackground = UIColor(red: 0.2, green: 0.2, blue: 1.0, alpha: 1.0)
    static let sundayText = UIColor(red: 1.0, green: 0.2, blue: 0.2, alpha: 1.0)
    static let sundayTextDisabled = UIColor(red: 1.0, green: 0.6, blue: 0.6, alpha: 1.0)
    static let sundaySelectionBackground = sundayText
}

// MARK: - Properties
@IBOutlet weak var calendarView: CVCalendarView!
@IBOutlet weak var menuView: CVCalendarMenuView!
@IBOutlet weak var monthLabel: UILabel!
@IBOutlet weak var daysOutSwitch: UISwitch!

fileprivate var randomNumberOfDotMarkersForDay = [Int]()

var shouldShowDaysOut = true
var animationFinished = true

var selectedDay:DayView!

var currentCalendar: Calendar?

override func awakeFromNib() {
    let timeZoneBias = 480 // (UTC+08:00)
    currentCalendar = Calendar.init(identifier: .gregorian)
    if let timeZone = TimeZone.init(secondsFromGMT: -timeZoneBias * 60) {
        currentCalendar?.timeZone = timeZone
    }
}


@IBOutlet weak var topCalBtnView = UIView()
@IBOutlet weak var sideBtnView = UIView()
@IBOutlet weak var calendarBigView = UIView()
@IBOutlet weak var filterBtn = UIButton()
@IBOutlet weak var calTable = UITableView()
@IBOutlet weak var calView = UIView()
var calendarContectObj = CVCalendarContentViewController()


convenience init() {
    self.init(nibName:nil, bundle:nil)
}

override func viewDidLoad() {
    super.viewDidLoad()
    self.navigationController?.navigationBar.isHidden = true

    //Calendar Stuff
    if let currentCalendar = currentCalendar {
        monthLabel.text = CVDate(date: Date(), calendar: currentCalendar).globalDescription
    }

    randomizeDotMarkers()
    // Do any additional setup after loading the view.
}

override func viewWillAppear(_ animated: Bool) {
    self.setLayout()
    navigationController?.interactivePopGestureRecognizer?.isEnabled = false

}

func setLayout(){
    ConstantFile.roundViewCorner(customVw: topCalBtnView!)
    ConstantFile.roundViewCorner(customVw: sideBtnView!)
    ConstantFile.roundViewCorner(customVw: calendarBigView!)
    ConstantFile.makeRoundBtnWithCornerRadius(btn: filterBtn!, cornerRadius: 0.02)
    ConstantFile.roundTableViewCorner(tableVw: calTable!)

}

//Mark:- IBAction
@IBAction func toggleMenuBtn(_ sender: Any) {
    let appDelegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
    appDelegate.centerDrawwerController?.toggle(MMDrawerSide.left, animated: true, completion: nil)
}

//MARK:- UITableView Delegate and Data Source
func numberOfSections(in tableView: UITableView) -> Int {
    return 1
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 4
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cellId")
    let cell = tableView.dequeueReusableCell(withIdentifier: "cellId", for: indexPath)
    return cell
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

//Mark:- Calendar Stuff
@IBAction func removeCircleAndDot(sender: AnyObject) {
    if let dayView = selectedDay {
        calendarView.contentController.removeCircleLabel(dayView)

        if dayView.date.day < randomNumberOfDotMarkersForDay.count {
            randomNumberOfDotMarkersForDay[dayView.date.day] = 0
        }

        calendarView.contentController.refreshPresentedMonth()
    }
}

@IBAction func refreshMonth(sender: AnyObject) {
    calendarView.contentController.refreshPresentedMonth()

    randomizeDotMarkers()
}

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()

    calendarView.commitCalendarViewUpdate()
    menuView.commitMenuViewUpdate()
}

private func randomizeDotMarkers() {
    randomNumberOfDotMarkersForDay = [Int]()
    for _ in 0...31 {
        randomNumberOfDotMarkersForDay.append(Int(arc4random_uniform(3) + 1))
    }
}

/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    // Get the new view controller using segue.destinationViewController.
    // Pass the selected object to the new view controller.
}
*/

}

Upvotes: 1

Views: 13060

Answers (2)

Dharma
Dharma

Reputation: 3013

In my quick search i found the function removeCircleLabel in CVCalendarContentViewController on GitHub.

// MARK: Delete circle views (in effect refreshing the dayView circle)
extension CVCalendarContentViewController {
    func removeCircleLabel(_ dayView: CVCalendarDayView) {
        for each in dayView.subviews {
            if each is UILabel {
                continue
            } else if each is CVAuxiliaryView {
                continue
            } else {
                each.removeFromSuperview()
            }
        }
    }
}

it clearly you can access this method from your controller. There is no protection.Please check your calendarView source with latest one.

Upvotes: 0

Aakash
Aakash

Reputation: 2269

By default all the methods, variable, constants, etc are internal. With internal protection level those methods, variable, constants, etc are not accessible outside a module.

removeCircleLabel(:_) is an internal method of the calendar module, you need make it public to access it.

Also do read: What is the 'open' keyword in Swift? This explains when you should use public and open.

Upvotes: 0

Related Questions