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…