WWDC24 SALE: Save 50% on all my Swift books and bundles! >>

Where / How do you store your sample code?

Forums > SwiftUI

@Bnerd  

How do you store your code for future use? So far I have been referring to complete projects and copied and pasted the formulas or code as needed. But I find it hard to remember what I used in each project.. How do you organize yourselves?

2      

@Bnerd asks for hints:

How do you store your code for future use?

Dear Future Me:

In my team, we joke about writing notes to our future selves. I don't know how many times past me has provided clear, detailed explanations to confused, dumbfounded current me. You might see in some of my code, I tend to write a lot of comments. If I can 'splain it so future me can understand it, then maybe someone else can benefit.

I keep my notes in Playgrounds.

When I first started using Playgrounds, I created a NEW playground for each concept. What a waste! You can create multiple playground pages in a single playground project. Give each playground page a nice title, such as "Buttons with Gradients", "Making a Button with SF Symbols" or "Buttons with Bindings".

Soon enough, you'll have a great collection of coding tips and hints.

See -> Learner's Recipe Book

2      

Select the code, then go to the Editor menu. At the bottom of the menu hit Create Code Snippet. You can name and edit your snippet. To use it in the future bring the snippet window up and double click the name of the code you want and it will paste it into your editor. The code snippet window also shows the Views Library and Modifiers Library. Lot of good information there.

2      

@Bnerd  

@Obelix

I had already a good Playground file when started to learn SWIFT, I will continue this one, thanks for the Pages tip.

I tried also other third party apps, but, Playground just makes sense!

2      

Save 50% in my WWDC sale.

SAVE 50% To celebrate WWDC24, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.