UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

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.