Combining server-side Swift, and Google’s Protocol Buffers by creating a simple server-client system.
In the first part of this blog post, we will build the server-side application. Second part of this blog post will be about building the client iOS application. Both applications will be built with Swift, and communication between them will be done using protocol buffers.
Two Ways of Implementing AnySomething
Sometimes, we can use a protocol as a standalone type. However, with a protocol like IteratorProtocol, this isn’t (yet) possible, because it has an associated type. The compile error says: “Protocol ‘IteratorProtocol’ can only be used as a generic constraint because it has Self or associated type requirements.”
RxKeyboard provides a reactive way of observing keyboard frame changes. Forget about keyboard notifications. It also perfectly works with
Since 2001, I’ve relied on an understanding of test execution flow in xUnit frameworks. But somewhere along the way, my understanding of the XCTestCase life cycle got messed up. I picked up an assumption that’s just wrong.
At best, it’s an assumption that can bloat our test runs. At worst, it can wreak havoc.
Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.
Database is a crucial part of any softwares nowadays, especially mobile applications. We use database to store various things, such as:
- app settings: to make it consistent between app launches.
- app context: to perserve the last screen user visited. (in case the app was killed, either intentionally by the user or automatically by the system to reclaim memory)
- data from a network reponse: to better support offline mode.
- anything you want to save for later submission when network is available.
- etc and etc…
Those are the things that make an app fast and responsive and eventually useful.
Therefore, we wanna make sure that our database works correctly. No mistakes or errors is tolerant here.
But how do we achieve that?
Well, you know, we write unit tests for it.
Swift differentiates between escaping and non-escaping closures. An escaping closure is one that is (potentially) called after the function the closure is passed to returns — that is, the closure escapes the scope of the function it is passed to as an argument.
Very comprehensive iPhone 7 review from real, daily user point of view.
After nearly two years spent using a 5.5-inch iPhone, I’m accustomed to not having a compact phone anymore. The iPhone 6 Plus and 6s Plus have reshaped my iPhone experience for a simple reason: they give me more of the most important device in my life.
Thus, I was a little skeptical – even surprised – when Apple gave me a gold 256 GB iPhone 7 review unit (with a leather case) two weeks ago. I didn’t think I would be able to enjoy a smaller iPhone, but, despite my initial resistance, I set up a fresh install of iOS 10 and used the iPhone 7 exclusively for two weeks.
I’m glad I did. While I’m still pining for a 7 Plus1, using the iPhone 7 showed me that there’s more to this year’s iPhones than the lack of a headphone jack.
In many ways, the iPhone 7 feels like a portable computer from the future – only in a tangible, practical way that is here with us today.
With iOS 10, tvOS 10, and watchOS 3, Apple is introducing a new framework called the UserNotifications framework. This brand new set of APIs provides a unified, object-oriented way of working with both local and remote notifications on these platforms. This is particularly useful as, compared to the existing APIs, local and remote notifications are now handled very similarly, and accessing notification content is no longer done just through dictionaries.
In this tutorial, I’ll go through the basics of this new framework and show how you can easily take advantage of it to support notifications for your applications.
This tutorial requires that you are running Xcode 8 with the latest iOS, tvOS, and watchOS SDKs.
Functions and closures are first-class objects in Swift: you can store them, pass them as arguments to functions, and treat them as you would any other value or object. Passing in closures as completion handlers is a common pattern in many APIs we all know and love.
When you pass a closure into a function in Swift 3, there’s a new wrinkle: the compiler assumes closure parameters are non-escaping by default. What does this mean? What’s the difference between an escaping and a non-escaping closure?