Access Control
Access Control
Access Control is a free Swift Academy lesson on CoddyKit — lesson 1 of 1. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Swift Academy learning path, one of 1 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Introduction
Hello,
Access Control restricts access to some of your code from code in other source files or modules.
Module: A module is a framework or application code distribution unit /
A module contains several source code files.
Source File:
The source file is a single source code file within the module.
Access Level
If the AL(Access Level) of a type is defined as private, the AL of all items belonging to the type will be private.
cont.
The private access identifier, the variable we have defined in front of it, the method, etc. makes it fully available in scope.
The purpose of the fileprivate access specifier is to be accessed by another class (class) / extension (extension) defined in the same file, except for the scope in which the variable is defined.
Especially when the extension is defined in the same source file, you cannot access the objects defined as private, while using fileprivate is a good option for this.
public
The public access delimiter is accessible across the entire module, but can be restrictive on subclasses and scopes when two modules are used.
And you may not be able to access variables and methods that you define with public access delimiter.
open
A class defined with public cannot be a subclass (superclass) in another module (ie it cannot be extended) and does not allow the methods it contains to be overridden.
So we need a more flexible access specifier than public.
In short, we can say open access limiter "more public than public".
cont.
Therefore, if you will use two modules and you want to access variables and methods in one module from another module, what you will do is simple: you will include the open-access provider at the beginning of the class you set as a superclass,
Likewise, it will be sufficient to define the method you want to override.
internal
In types other than enum, if the type is defined as public, the items are automatically internal. However, if the Enum type is defined publicly, the elements of the Enum will be public.
public enum Direction { case North, South, East, West }
//each case is also has public access level.Subclassing
Subclassing
We can create a subclass of any class. It is sufficient for the class to be accessible from the relevant context.
A subclass cannot have more access levels than its upper class. Because the upper class wraps the lower class.
The overridden method may be more accessible than the overridden method in the upper class.
public class ClassA {
//method private tanimlanmis
private func aPrivateMethod() {}
internal func anInternalMethod() {}
}
internal class ClassB: ClassA {
// The overridden method is defined internally. Access level has increased even more.
override internal func anInternalMethod() {}
}cont.
Constants, Variables, Properties, and Subscripts Access Level
A constant, variable, or property cannot need less restricted access than the type it is linked to. Public property is like public class.
Getters and setters for constants, variables, properties, and subscripts also have the same access level as the type they belong to, like constantly or variables.
Congratulations
Congratulations 🎉
In this lesson, we learned Access Control on Swift.
We have now completed the Swift for Beginners course.
Let's start the exam and get our certificate. 🌟

Frequently asked questions
Is the “Access Control” lesson free?
Yes — the full text of “Access Control” is free to read here on the web, and the Swift Academy course includes 1 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Swift Academy course, upgrade to CoddyKit PRO.
What will I learn in “Access Control”?
Access Control You practise Swift Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Swift Academy?
No prior experience is required. Swift Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 1, so you can start here or from the beginning and move at your own pace.
How long does the “Access Control” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Swift Academy lesson?
Yes. Every Swift Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.