How to create a variable that can be used or changed in all swift files

Hey, im new here. And I need to share a variable between files, settings and home. I've searched all over and found solutions, but I just don't understand what to do.

Answered by ssmith_c in 793955022

I think you need to re-phrase your question. The question in your title is fairly easy to answer. By default, a variable declared in any one .swift file in your program is available to any other .swift file in your program. (search for "Access Levels" in the Swift Programming Language reference from Apple).

I don't understand what you mean by "files, settings and home" here.

I think you need to re-phrase your question. The question in your title is fairly easy to answer. By default, a variable declared in any one .swift file in your program is available to any other .swift file in your program. (search for "Access Levels" in the Swift Programming Language reference from Apple).

I don't understand what you mean by "files, settings and home" here.

Welcome to the forum.

as @ssmith_c has told, your question is hard to understand.

What is your environment ? Playground ? app development ? SwiftUI or UIKit…

What is home ? Are settings the settings of your app in iOS settings ?

If so, you have to create a settings bundle.

See complete details here: https://makeapppie.com/2016/03/14/using-settings-bundles-with-swift/

So, please explain so that we can better help.

How to create a variable that can be used or changed in all swift files
 
 
Q