Hi! This is the 3rd swifty week. Time flies so fast! The App Store’s Holidays will be December 23 to 27 (Pacific Time). We’ll have a busy week more than usual. By the way, I’m very excited to attend try!Swift Tokyo 2017. If you have a chance to go the conference, feel free to talk to me
Congrats - Best of 2016
it will warn you whenever any slow functions are added to the project. … Add two flags: -Xfrontend and -warn-long-function-bodies=100, where 100 is the number of milliseconds you’d like the warning threshold to be
Looks useful and you can try in a second.
Swift will try to optimize method dispatch whenever it can. For instance, if you have a method that is never overridden, Swift will notice this and will use direct dispatch if it can. This optimization is great most of the time, but will often bite Cocoa programmers who are using the target / action patterns
A very thorough summary of how method dispatch works in various parts of Swift: https://t.co/DWWMUVtgLv— Chris Lattner (@clattner_llvm) December 7, 2016
If you haven’t read the article, I recommend you to read!
Tuples can be useful when more than one value type can provide more useful information about the outcome of a behavior or action than simply returning a single value.
The content is really simple and clear. I relearned Tuples in Swift.
The key takeaway of this article is that private entities don’t need to be unit tested. Unit testing is a form of black-box testing. This means that we don’t test the implementation of the AccountViewViewModel struct, we test its specification.
That makes sense for me. The change from private to wider access control just for a unit test is too bad.
The problem with the third option is that the nil-coalescing operator ?? requires matching types — if the left operand is a T?, the right operand must be a T. Applied to the example above, this means I can provide another Int as a default value, but not a string — which is what I’d like to do in this situation.
print("The value is \(someValue ??? "unknown")") looks natural.
SwiftPM has two new major features built on top of the new resolver:
- Editable Packages
- Version Pinning
SwiftPM is evolving so fast! Cool.
The brackets clearly indicate both the argument role and creates an affordance, a specific visual indication that you can expand the set by introducing more options. Without brackets, this may not be intuitively obvious to someone less familiar with option sets.
In my opinion, I prefer options with brackets.
Let’s write a minimal Reactive program. From scratch. Let’s reinvent a very tiny wheel, for the purpose of really understanding. When there’re so few lines of code, there’s not much to be explained. It’s all there, at a glance.
I could roughly learn a core of RxSwift.
As you can see, the syntax and structure has been inspired by the things I’ve learned from using Swift’s functional programming APIs. We’ve traded in double closure API for a sequence of higher order functions and now our code reads a lot better and the compiler is fighting for us when we’re writing new lines and copy/pasting old ones.
I like enhancing the interface by not using any libraries.
Let’s get down to bits and bytes! Abstraction is great, but sometimes it’s useful to dig down. In this GOTO Copenhagen 2016 session, we’ll explore exactly how Swift lays out data in memory, including both your own variables and Swift’s internal data structures.
When working with closures in Swift, be mindful of how you are capturing variables, particularly selfs. If self is retaining the closure in any way, make sure to capture it weakly. Only capture variables as unowned when you can be sure they will be in memory whenever the closure is run, not just because you don’t want to work with an optional self. This will help you avoid memory leaks, which leads to poor performance and crashes.
To judge whether you capture
Self Strongly or not is an important thing for iOS developer.
In Swift 3 now that we can have generic typealiases, I use the above snippet quite often which declares a closure of a generic type (which could be any object you want) with void return type. We can use it in the following way which make things quite readable and easy to use 🚀:
This is one of the favorite snippets in Generic Typealias.
With default implementations, you can give existing protocols common and automatic behavior, much like a base class but better since it can apply to structs and enums too.
Our Swift 3 migration is coming to a close. So far, 52 of the 72 algorithms have been converted to Swift 3.
I saw some famous algorithms in Swift Algorithm Club. The implementation is really great.
I’ll outline a simple method that enables us - in a single Swift package - to embed C code along with a wrapper Swift library module. This allows us to craft C code for tasks C is good at, with the benefits of being able to easily integrate the C code with other Swift modules by writing a pure Swift (and Swifty) thin wrapper on top.
A tiny log console to display information while using your iOS app. Written in Swift 3.
A convenient wrapper around the UI code that is often needed for displaying debug menus.
Reactive + Automaton + VTree in Swift, inspired by Elm.
VirtualDOM for Swift (iOS, macOS)
Is it time to understand ownership for Swift4??
I found out that Tokyo (23 wards, the most crowded part of Tokyo), has 3 times more people living than that of Berlin, and yet, they are crammed into less area (70 % of Berlin)
I was surprised I could know life diff between Tokyo and Berlin.
This happened by accident. I was so interested in open source Swift when it was announced, and I wrote a few blog posts on my personal site. The community seemed to enjoy and appreciate them, so I decided to move it to a dedicated site and make it “a thing”.
This is the Second Edition of the best selling book that gets you up and going quickly writing code in the Swift Programming Language.
I bought it the other day. Look forward to reading it
Have a lovely week <3