Skip to content

ahmetbostanciklioglu/Static

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 

Repository files navigation

🧬 Swift Basics: Static

A concise, runnable Swift Playground demonstrating static type properties.

Platform Swift Playground Stars Last Commit

πŸ“– Overview

In Swift, a static property belongs to the type itself rather than to any single instance β€” every instance shares the one stored value. This Playground is a short, runnable learning example that shows exactly that: a struct with a static counter that is incremented from the initializer, so the value keeps climbing across every instance created.

It is meant as a quick reference for understanding the difference between instance properties and type-level (static) properties.

🧠 What it covers

  • Declaring a static stored property on a struct.
  • How a static property is shared across all instances rather than copied per-instance.
  • Mutating a type property from inside an init, so it accumulates as new instances are created.
  • Accessing a static property through the type name (StaticStruct.property2) versus reading an instance property (staticObject1.property).

πŸš€ Getting Started

git clone https://github.com/ahmetbostanciklioglu/Static.git
cd Static

Unzip StaticTypes.playground.zip, then open StaticTypes.playground in Xcode. The Playground executes automatically and prints the results in the console / sidebar.

πŸ“‹ Requirements

  • Xcode 12 or later
  • Swift 5.0+
  • Runs on the iOS Playground target

πŸ§‘β€πŸ’» Author

Ahmet BostancΔ±klΔ±oğlu β€” @ahmetbostanciklioglu Β· ahmetbostancikli@gmail.com

⭐ If this helped you, consider giving the repo a star!

About

A concise, runnable Swift Playground demonstrating static (type) properties in a struct.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors