Imagine a registration flow with a few steps (screens) and each of them fils some information about a user. Finally, you have to construct the user by the data from the previous steps... how?
There're many solutions to achieve it - using optional properties and just pass an object over the screens; maybe create a dictionary with filed data and so on.
But I really adore this solution by utilizing KeyPath's, Generics and subscripts to create a partial object. Of course, in no way without downsides, but they're so minor and it doesn't prevent to use it!
p.s. Recently I already posted the similar article, but this one looks really great with more details about a realization.
https://josephduffy.co.uk/partial-in-swift
#swift #keypath
There're many solutions to achieve it - using optional properties and just pass an object over the screens; maybe create a dictionary with filed data and so on.
But I really adore this solution by utilizing KeyPath's, Generics and subscripts to create a partial object. Of course, in no way without downsides, but they're so minor and it doesn't prevent to use it!
p.s. Recently I already posted the similar article, but this one looks really great with more details about a realization.
https://josephduffy.co.uk/partial-in-swift
#swift #keypath
A bit of undocumented Swift feature. Have you known, that you can set a default type for associatedtype?
associatedtype A: Foo
associatedtype B = Foo // default
https://swiftrocks.com/swift-associated-types-with-default-values.html
#swift
associatedtype A: Foo
associatedtype B = Foo // default
https://swiftrocks.com/swift-associated-types-with-default-values.html
#swift
Swiftrocks
Swift Associated Types With Default Values
I was browsing the Swift forums when I stumbled across a discussion regarding an undocumented feature of Swift (as of this post's date): the ability to give associated types a default value.
A bit of array performance - need to be aware when it's preferable to use reserveCapacity rather than a simple array allocation. Be familiar with the Big-O notation! 😉
https://www.hackingwithswift.com/articles/128/array-performance-append-vs-reservecapacity
#swift #performance
https://www.hackingwithswift.com/articles/128/array-performance-append-vs-reservecapacity
#swift #performance
Hacking with Swift
Array performance: append() vs reserveCapacity()
Sometimes its faster to let Swift figure things out for you
There's a new hype post about snapshot testing on Twitter provided by guys from the Point Free. Many fellows liked it and highly recommend to try it out, so I can't miss to share it with you.
https://www.pointfree.co/blog/posts/23-snapshottesting-1-0-delightful-swift-snapshot-testing
#iOS #swift #Tests #snapshot_testing
https://www.pointfree.co/blog/posts/23-snapshottesting-1-0-delightful-swift-snapshot-testing
#iOS #swift #Tests #snapshot_testing
www.pointfree.co
SnapshotTesting 1.0: Delightful Swift snapshot testing
Today we are open sourcing SnapshotTesting 1.0: a modern, composable snapshot testing library built entirely in Swift!
Swift becomes more safety with each new release and this article describes what's new here. Sounds a bit complicated but interesting to read though :)
“By shipping with full exclusivity enforcement enabled in Release builds, Swift 5 helps to eliminate bugs and security issues, ensure binary compatibility, and enable future optimizations and language features.”
https://swift.org/blog/swift-5-exclusivity/
#swift
“By shipping with full exclusivity enforcement enabled in Release builds, Swift 5 helps to eliminate bugs and security issues, ensure binary compatibility, and enable future optimizations and language features.”
https://swift.org/blog/swift-5-exclusivity/
#swift
Swift.org
Swift 5 Exclusivity Enforcement
The Swift 5 release enables runtime checking of “Exclusive Access to
Memory” by default in Release builds, further enhancing Swift’s
capabilities as a safe language. In Swift 4, these runtime checks were
only enabled in Debug builds. In this post, I’ll first…
Memory” by default in Release builds, further enhancing Swift’s
capabilities as a safe language. In Swift 4, these runtime checks were
only enabled in Debug builds. In this post, I’ll first…
Every time I'm going to solve some interesting programming problem, implement a network layer, a collection with different types of cells and so on, PAT (protocol with associated type) is the first thing that comes to mind, it'd be awesome to implement it this way, I tell myself. Nevertheless, it sucks when Sequence or saving to a variable happens. But I'm not upset - googling "Swift type erasure", implementing _Box, AnyFoo and I'm happy again, not today though...
What I'm talking about? So, if you've felt yourself in the same situation, try thoughtfully reading this article. And maybe next time you won't spend much time on this.
http://robnapier.net/start-with-a-protocol
#swift
What I'm talking about? So, if you've felt yourself in the same situation, try thoughtfully reading this article. And maybe next time you won't spend much time on this.
http://robnapier.net/start-with-a-protocol
#swift
robnapier.net
Protocols I: "Start With a Protocol," He Said - Cocoaphony
In the beginning, Crusty In 2015, at WWDC, Dave Abrahams gave what I believe is still the greatest Swift talk ever given, and certainly the most …
Approximate Equality for Floating Point.
finally.🤞
https://github.com/apple/swift-evolution/blob/master/proposals/0259-approximately-equal.md
#swift #proposal
finally.🤞
https://github.com/apple/swift-evolution/blob/master/proposals/0259-approximately-equal.md
#swift #proposal
GitHub
swift-evolution/0259-approximately-equal.md at main · apple/swift-evolution
This maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - swift-evolution/0259-approximately-equal.md at main · apple/swift-evolution
I've been waiting for this for so long - Swift 5.1 with Module Stability finally!
https://swift.org/blog/swift-5-1-released/
#swift
https://swift.org/blog/swift-5-1-released/
#swift
Swift’s team is continuing making it easier to contribute to the Swift STL as well as to try out new features before their official release using a new Preview Package.
https://swift.org/blog/preview-package/
#swift #evolution #proposal
https://swift.org/blog/preview-package/
#swift #evolution #proposal
Swift.org
Standard Library Preview Package
I’m excited to announce a new open-source package and an enhancement to the Swift Evolution process: the Standard Library Preview package! The preview package provides access to functionality that has been accepted into the Swift standard library through…
Apple continues integrating iPad apps to Mac using the Catalyst project.
p.s. I hope it works better than Xcode playground. 🙏
https://9to5mac.com/2020/02/11/apple-launches-swift-playgrounds-app-for-the-mac/
#swift
p.s. I hope it works better than Xcode playground. 🙏
https://9to5mac.com/2020/02/11/apple-launches-swift-playgrounds-app-for-the-mac/
#swift
9to5Mac
Apple launches Swift Playgrounds app for the Mac, built using Catalyst
Apple’s Swift Playgrounds application is now available on Mac. The app was originally released for the iPad in 2016, but now Apple has brought it to the Mac as well using its Catalyst platform. Apple’s Swift Playgrounds platform makes it easy for anyone to…
Swift’s team has announced a new open-source library to parse command-line arguments.
https://swift.org/blog/argument-parser/
#swift
https://swift.org/blog/argument-parser/
#swift
Swift.org
Announcing ArgumentParser
We’re delighted to announce ArgumentParser, a new open-source library that makes it straightforward — even enjoyable! — to parse command-line arguments in Swift.
I always prefer writing ==
https://twitter.com/nicklockwood/status/1324491275291295749
#swift #performance
f
or bool comparison rather than
! for better readability, but ... oh, common, it dramatically slower.https://twitter.com/nicklockwood/status/1324491275291295749
#swift #performance
Twitter
Nick Lockwood
TIL writing if foo == false {} Compiles dramatically more slowly in Swift than: if !foo {} And you should probably always use the latter even if you find it less readable: https://t.co/9MI7XteFRZ