-
Example Structs
When making a 'Struct', particularly if it's to be used with SwiftUI, it's a good idea to add an example. static let example = Location(id: UUID(), name: "Buckingham Palace", latitude: 51.501, longitude: -0.141) This is particularly helpful for Previews.
-
SVG Editor
Maybe try SVG-Edit
-
Fun on the menu
Might be fun to try the Ice menu bar app.
-
My web logfiles
Web logs are in ~/.config/valet/Log config files are at ~/.config/valet/Nginx
-
SwiftUI Navigation
An interesting thread on SwiftUI Navigation https://hachyderm.io/@teissler/112476974255668785
-
SF Symbols - but safer
Go get SF Safe Symbols.
-
@Bindable vs @Binding
Use @Bindable to access a shared instance of a Class (that's @Observable). Use @Binding to access a shared simple value, ie a Boolean or Double or array etc (which can't be @Observable). Note - in both cases, the original thing is created with @State.
-
get text from URL
A super-basic way to get plain text from a URL is: struct ContentView: View { @State private var mytext = "loading..." func loadData() async { do { let url = URL(string: "https://thespia.com/test/")! mytext = try…
-
Swift code to learn from
There's a dev called Mahdi Bchatnia who made Autoclick (as well as a bunch of other interesting apps). And he (she? they?) have kindly made a bunch of useful code available on Github for our learning pleasure.
-
The Double Diamond
Discover, Define, Develop, Deliver Read about it here or learn more here.
-
Sharing @Observables through the environment
First, you want an Observable class. @Observable class Player { var name = "Anonymous" var highScore = 0 } In your top-level View, you want a @State var and you want to stick it in the subviews via enviornment(), thus: struct ContentView: View { …
-
Safari but cleaner
I haven't tried it yet, but the StopTheMadness Safari extension (for iPhone and also Mac) looks like it removes a bunch of enshittification that web devs (or web devs' corporate overlords) like to put on "modern" websites. It's not cheap ($23 AUD) but it…
-
A Font of Beauty
Robert Green’s facsimile of the Doves Press typeface is lovely. It's not free but it's worth it. There's one version of the font for regular size text, and a slightly tweaked "Headline" version for larger text. Either (or both) can be bought here.
-
.onAppear() and fatalError()
See Paul https://www.hackingwithswift.com/books/ios-swiftui/running-code-when-our-app-launches
-
Watching for Change
"When working with structs, the @State property wrapper keeps a value alive and also watches it for changes. On the other hand, when working with classes, @State is just there for keeping object alive – all the watching for changes and updating the view…
-
Animated again and again
to add animation to some view when it changes, add .animation(.default, value: someVariable). This will apply the .default animation as an implicit animation, whenever the value of that variable changes. Alternatively, you can add the .animation()…
-
get location
https://www.hackingwithswift.com/read/22/2/requesting-location-core-location https://medium.com/@nayananp/user-location-in-swift-with-cllocationmanager-4a447311d7d8
-
location auth status
https://stackoverflow.com/questions/64073811/authorizationstatus-for-cllocationmanager-is-deprecated-on-ios-14 https://developer.apple.com/documentation/corelocation/cllocationmanager/3563952-authorizationstatus https://developer.apple.com/documentation/c…
-
distance between locations
https://www.ralfebert.com/swift/cllocationcoordinate2d-distance/
-
Fading away
Have some sort of transition, maybe fade in/out, when we change days and pins move.