Здравствуйте. Немного не понимаю, в курсе Networking для MainViewController используется код:
import UIKit
enum Actions: String, CaseIterable {
case downloadImage = "Download Image"
case get = "GET"
case post = "POST"
case ourCourses = "Our Courses"
case uploadImage = "Upload Image"
}
private let reuseIdentifier = "Cell"
private let url = "https://jsonplaceholder.typicode.com/posts"
class MainViewController: UICollectionViewController {
let actions = Actions.allCases
// MARK: UICollectionViewDataSource
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return actions.count
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as! CollectionViewCell
cell.label.text = actions[indexPath.row].rawValue
return cell
}
// MARK: UICollectionViewDelegate
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let action = actions[indexPath.row]
switch action {
case .downloadImage:
performSegue(withIdentifier: "ShowImage", sender: self)
case .get:
NetworkManager.getRequest(url: url)
case .post:
NetworkManager.postRequest(url: url)
case .ourCourses:
performSegue(withIdentifier: "OurCourses", sender: self)
case .uploadImage:
print("Upload Image")
}
}
}
При этом private свойства
private let reuseIdentifier = "Cell"
private let url = "https://jsonplaceholder.typicode.com/posts"
Объявлены вне класса MainViewController. Как они могут быть тогда там доступны? Мне казалось, что private ограничивает доступ только в пределах класса или его расширений.