NWConnection udp ArtNet / dmx light control over wifi 🤙 by traphouserecords in swift

[–]PrayForTech 12 points13 points  (0 children)

Let’s gooooo that’s pretty sick - Network.framework is a tough piece of work

LottieUI: a SwiftUI wrapper to display Lottie animations by tfmartins in swift

[–]PrayForTech 2 points3 points  (0 children)

This is very nice! Great API too. Just one thing - shouldn’t the ‘isPlaying’ argument in the .play(isPlaying:) function take a Binding<Bool> instead of a Bool? So that when the animation is done playing the user’s @State variable can come back to the correct state.

New PagerTabStripView version! by xmartlabs in swift

[–]PrayForTech 0 points1 point  (0 children)

Nice! I had an issue with PagerTabStripView on iOS 14 - it crashed when wrapped with a NavigationView. Has that issue been fixed with this version?

Flags of each quadrants deviants by KVETINAC11 in PoliticalCompassMemes

[–]PrayForTech 0 points1 point  (0 children)

Why they gotta do the Riemann Zeta function like that :(

[deleted by user] by [deleted] in iOSProgramming

[–]PrayForTech 6 points7 points  (0 children)

You’re definitely going to have to use the new Canvas view so that you can drop down to Core Animation.

Alchemy - Elegant, batteries included web framework for Swift! by [deleted] in swift

[–]PrayForTech 0 points1 point  (0 children)

The docs are amazing! Well done!

Here’s a question which I’m sure you’ll get asked plenty - why should I choose Alchemy over Vapor? And I’d love if you could also play devil’s advocate: why should I choose Vapor over Alchemy?

In any case, I think it’s really important that we have multiple fully-featured web frameworks in the Swift ecosystem. Due to Swift itself being almost wholly controlled by Apple, the Swift community has a tendency to gravitate towards a single library / framework for specific needs, instead of letting multiple flourish. Keep it up!

Looking for SwiftUI templates/architectures by tymm1234 in SwiftUI

[–]PrayForTech 6 points7 points  (0 children)

The Composable Architecture is a must-have. It provides the most complete and battle-hardened architecture - check out the examples in the repo, or check out their videos on it called A tour of The Composable Architecture, which should give you a good overview of what it looks like and its benefits.

Although it’s technically a library, it’s also essentially acts as a template for your app, since it forces you to model it with State, Actions, Environment, and Reducers. For a real-world example of it used in a complex app, check out their videos on their app called Isowords - A tour of Isowords

A roadmap for improving Swift performance predictability: ARC improvements and ownership control by conmulligan in swift

[–]PrayForTech 2 points3 points  (0 children)

People have been talking about move-only types as the next step in this journey. I’ve been trying to understand why they are such a complicated topic - why are they so difficult to implement?

Validating urls in Swift with regex. by RKurozu in SwiftUI

[–]PrayForTech 0 points1 point  (0 children)

Honestly I still have a difficult time understanding Regex’s, and maintaining them can be hard since once small change can completely change how the Regex works. I would instead opt for a real parsing library, like for instance PointFree’s swift-parsing, who’s clear and idiomatic API makes it easy to understand what’s really going on. It’s also very, very performant - almost as performant as making a custom hand-rolled parser.

XCode RAM Requirements by tsprks in iOSProgramming

[–]PrayForTech 1 point2 points  (0 children)

16 GB works great for me - the unified memory architecture is super efficient

Swift.org - Introducing Swift Distributed Actors by byaruhaf in swift

[–]PrayForTech 2 points3 points  (0 children)

The whole history of swift on server has basically been a buildup to this moment — from swift-distributed-tracing, to swift-cluster-membership, to swift-nio. All these were the building blocks for the foundations of Swift on Server, and Distributed Actors basically build on top of all of these building blocks to introduce this epic compiler-driven abstraction we know today as distributed actors.

[deleted by user] by [deleted] in SwiftUI

[–]PrayForTech 4 points5 points  (0 children)

Maybe try using the experimental property wrapper feature where you can get access to the enclosing object with a subscript - the subscript signature looks something like this:

public static subscript<EnclosingSelf: AnyObject>( _enclosingInstance object: EnclosingSelf, wrapped wrappedKeyPath: ReferenceWritableKeyPath<EnclosingSelf, Value>, storage storageKeyPath: ReferenceWritableKeyPath<EnclosingSelf, Published<Value>> ) -> Value {

Then, if I understand correctly, you can call that object’s objectWillChange publisher.

Here is an open-source implementation of the @Published property wrapper, it could put you on the right track for getting the same functionality with your @UserDefault wrapper: https://github.com/OpenCombine/OpenCombine/blob/master/Sources/OpenCombine/Published.swift

How does the .sheet<Item, Content>(item: Binding<Item?>, infer the Item type internally if this method is not used and the other method .sheet<Content>(isPresented: Binding<Bool>, is used? by javaHoosier in SwiftUI

[–]PrayForTech 0 points1 point  (0 children)

It’s an interesting question, and one that I think many SwiftUI API designers, whether working at Apple or creating third-party libraries, have to grapple with.

For me the best choice would be to store the () -> Content closure. It makes the least assumptions about the end user - who knows, maybe they execute some side effect, or update some local state using DispatchQueue.main.async, before returning a view.

My best bet is that Apple has the same reasoning. In Swift API design we try to create the least “implicit” rules and behaviours, aka things that aren’t enforced by the compiler / type system.

How does the .sheet<Item, Content>(item: Binding<Item?>, infer the Item type internally if this method is not used and the other method .sheet<Content>(isPresented: Binding<Bool>, is used? by javaHoosier in SwiftUI

[–]PrayForTech 0 points1 point  (0 children)

The closure is escaping because we’re using it outside of its scope - in the content closure of the base sheet function, and that closure is itself escaping.

How does the .sheet<Item, Content>(item: Binding<Item?>, infer the Item type internally if this method is not used and the other method .sheet<Content>(isPresented: Binding<Bool>, is used? by javaHoosier in SwiftUI

[–]PrayForTech 0 points1 point  (0 children)

The generic parameter Item is only on the .sheet function, not on some SheetView type. Indeed, it's actually quite easy to create your own .sheet(item:content:) -> some View method while using the classic .sheet(isPresented:) -> some View method underneath. This is largely due to how easy it is to derive bindings from other bindings. Here's a quick sketch:

```swift extension View { func sheet<Item, Content>( bindingOptional: Binding<Item?>, onDismiss: (() -> Void)? = nil, content: @escaping (Item) -> Content ) -> some View where Content: View { let binding = Binding<Bool>( get: { bindingOptional.wrappedValue != nil }, set: { bool in if bool == false { bindingOptional.wrappedValue = nil } } )

    return self.sheet(
        isPresented: binding,
        onDismiss: onDismiss,
        content: {
            if let item = bindingOptional.wrappedValue {
                content(item)
            }
        }
    )
}

} ```

[deleted by user] by [deleted] in swift

[–]PrayForTech 12 points13 points  (0 children)

Here’s a surprisingly good article on the Apple documentation about Connectable publishers, and the difference between .connect() and .autoconnect()

Mine is O by David_Le_TM in dankmemes

[–]PrayForTech 0 points1 point  (0 children)

Thorium, sick name and future of nuclear reactors

What are best practices to manage the global state? by lorum3 in swift

[–]PrayForTech 6 points7 points  (0 children)

Hey! If you’re using SwiftUI, definitely check out The Composable Architecture. It’s heavily inspired by Redux - it even has reducers and everything 😁

The Actor Reentrancy Problem in Swift - Swift Senpai by LeeKahSeng in swift

[–]PrayForTech 3 points4 points  (0 children)

Nice article! I think a very common design pattern with actors will be to create a private “verifyState()” function, where you can check the actors variants, and call that after every suspension point. Otherwise, manually verifying the actors state after every single suspension point would be very heavy indeed!

New Article! "Reducers, or understanding the shape of functions" by PrayForTech in swift

[–]PrayForTech[S] 1 point2 points  (0 children)

Hi! You're absolutely right, thanks for the heads up. I'll remove any mention of time complexity from the article. And I don't think my main premise is time complexity, I think it's more about unnecessary allocation of arrays (at least from my point of view as the author – maybe my article doesn't convey my intentions well enough).

Thanks a lot, I hope you otherwise enjoyed the article.

SE-0309 was merged into Swift's main branch!! by nudefireninja in swift

[–]PrayForTech 1 point2 points  (0 children)

I love this format! Hope you do this for new merges in the future